Setup FeatureBoard in Remix
Install the NodeJS SDK
See the NodeJS SDK docs for more information.
Integrating with Remix
To use FeatureBoard with Remix, you will need to extend the AppLoadContext
to expose the FeatureBoard client to your routes.
This is a GUIDE on a recommended setup using Remix and FeatureBoard. You may need to adjust this to fit your needs.
Background
Remix has nested routes and a single AppLoadContext
is shared across all routes, this means the current user is normally fetched within loaders. This is a problem for FeatureBoard as it needs to know the current user to determine which features are enabled.
To solve this, the pattern we recommend is a function on the AppLoadContext
which returns a FeatureBoard client for the current user. null
can also be passed in contexts where you do not have a user.
If there is any other context which is required to determine which features are enabled, they can be passed into this function.
Steps - Manual Server
These steps assume you are using remix in Manual Mode
Any steps prefixed with [TypeScript only] can be skipped for JavaScript projects. For more information about FeatureBoard’s TypeScript support, see the TypeScript docs.
[TypeScript only] Create a app-load-context.ts
file
This allows you to expand the TypeScript types for the AppLoadContext
interface.
[TypeScript only] Create a features.ts
file
This can be done manually e.g.
Or automatically via the cli tool
By running npx @featureboard/cli login
, then npx @featureboard/cli code-gen --template typescript --output ./
to generate a features.ts file in the output path or update an existing one.