Remix
Run bknd inside Remix
Installation
To get started with Remix and bknd you can either install the package manually, and follow the descriptions below, or use the CLI starter:
Create a new Remix CLI starter project by running the following command:
Serve the API
Since Remix doesn’t support middleware yet, we need a helper file to initialize the App to import from. Create a new file at app/bknd.ts
:
Create a new api splat route file at app/routes/api.$.ts
:
For more information about the connection object, refer to the Database guide.
Now make sure that you wrap your root layout with the ClientProvider
so that all components share the same context. Also add the user context to both the Outlet
and the provider:
Enabling the Admin UI
Create a new splat route file at app/routes/admin.$.tsx
:
Example usage of the API
Since the API has already been constructed in the root layout, you can now use it in any page: