Skip to main content
This guide will help you get started with Nile Auth and NextJS. This guide outlines the steps required to configure and integrate authentication in your application. This guide assumes that you have already created a NextJS application, if you haven’t, you can use the Quickstart to get started.
If you have not done so yet, be sure you have obtained credentials from the console.
1

Install packages

2

Configure routes

Configure the splat route. Be sure to add the nextJs extension, it will handle passing the client requests (next/headers), as well passing the correct headers on server-side calls automatically.
app/api/[...nile]/nile.ts
app/api/[...nile]/route.ts

Server actions and RSC

The build-in components found in @niledatabase/react will request information client side. If you’d like to hydrate them, @niledatabase/server functions can be called.

Example: Verify email address

app/verify-email/page.tsx
Server actions work in a similar way. Here’s an example of an action that is called to verify a user’s email address. An action like this requires SMTP to be configured in the console.
nile.users.verifySelf mirrors the client-side call to /api/auth/verify-email. All server side calls can be called from a client based on their configured route.

Client side

While in most cases, actions would be used to handle the calls to nile-auth, it is possible to use @niledatabase/react which can do a lot of the heavy lifting for you, especially when it comes to client-side authorization, or quickly getting a demo app up and running.

Example: Hydrated sign up / dashboard page

For something like SSO, the easiest thing to do is create a button for signin in, and @niledatabase/client to handle the rest