Skip to main content

SSR Support

This guide covers server-side rendering considerations for Next.js, Remix, and other SSR frameworks.

The Challenge

The Privacy Boost SDK uses WebAssembly and browser APIs that aren’t available on the server. You need to ensure the SDK only loads on the client. No bundler configuration is needed for the WebAssembly itself: it ships inside the package as base64.

Next.js

App Router

Pages Router

Dynamic Component Import

For components that use SDK hooks:

Remix

Client-Only Provider

Hydration Mismatch Prevention

useIsClient Hook

Conditional Rendering

Environment Variables

Next.js

Remix

Testing SSR

Best Practices

  1. Always use ‘use client’ directive for components using SDK hooks
  2. Dynamic imports for large components to reduce bundle size
  3. Provide fallbacks for loading and server-rendered states
  4. Avoid window/document access without checking environment
  5. Use environment variables with NEXT_PUBLIC_ prefix for client access

Next Steps