Frameworks
React Router
Run bknd inside React Router
Installation
To get started with React Router and bknd you can either install the package manually, and follow the descriptions below, or use the CLI starter:
Create a new React Router CLI starter project by running the following command:
Serve the API
Create a helper file to instantiate the bknd instance and retrieve the API:
app/bknd.ts
For more information about the connection object, refer to the Database guide.
Create a new api splat route file at app/routes/api.$.ts
:
app/routes/api.$.ts
Enabling the Admin UI
Create a new splat route file at app/routes/admin.$.tsx
:
app/routes/admin.$.tsx
Example usage of the API
You can use the getApi
helper function we’ve already set up to fetch and mutate:
app/routes/_index.tsx