Skip to content

[FEATURE] SSR Support #1117

Open
Open
@RedbackThomson

Description

@RedbackThomson

Requirements

The existing OpenFeature React SDK relies solely on the @openfeature/web-sdk package, intended to run client side (in the browser). When attempting to use the React SDK inside a NextJS application with SSR enabled, NextJS fails to render the page on the server and in the best case causes the page to stutter as it hydrates but in the worst case causes the application to fail to render at all.

Today, in order to support SSR, our code needs to conditionally disable the use of the React SDK hooks (and the Web client) and replace them with the same call to the NodeJS SDK when it detects the code is executing within an SSR context (by checking window === undefined).

Ideally the React SDK would have an option to natively support SSR in which it would:

  • Detect that it was running within an SSR context
  • Switch to a @openfeature/server-sdk client
  • Automatically bootstrap the web client provider with the resolved flags, for instant hydration

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions