Skip to main content
This guide explains how to integrate Nile Database with Remix and set up routes for handling various HTTP requests (GET, POST, PUT, DELETE). Additionally, you’ll see how to include client-side components for user authentication and interaction using Nile’s React SDK.
This guide assumes you are running an application similar to npx create-react-router@latest --template remix-run/react-router-templates/node-postgres, and have already updated your .env file from the installation

1

Update .env

Update your .env file with DATABASE_URL so drizzle works.
.env
2

Update to node-pg

Update /server/app.ts
server/app.ts
Along with that change, sync up database/context.ts to be sure its using the same types, changing from PostgresJsDatabase, to NodePgDatabase. In addition, there are may be some compatibility changes that need handled if you are updating an existing project based on our compatibility
3

Add Nile to the server

Now we need to add the nile instance and route handlers to allow our server to respond to authentication, user, and tenant requests.
app/routes/api.$.ts
Then update your route config to allow the handlers to work
app/routes.ts

Creating a loader

In some cases, you may want to create specific action and loader around the API, to do that, use the server side functions in the sdk in your loader. This code loads and updates a user’s profile.