Skip to main content
1

Prerequisites

Nile provides a cloud offering to help build multi-tenant apps. You can also get started with Nile’s Docker image and try Nile locally. Join our discord to give feedback or ask questions about running Nile locally.
  • Docker
  • Postgres client. We’ll use psql in this guide.
2

Run the Docker Container

This will start a Postgres database with Nile extensions installed. It will also start Nile Auth (optional). If this is the first time you are running the container, it will also pull the latest image,create the test database and the 00000000-0000-0000-0000-000000000000 user.
3

Connecting to the Database

You can use psql with the following connection string:
Or, if you are using a different client, you use the following connection details:
4

Test Nile Auth

Nile Auth service is running and listening on port 3000. We will do a curl to check if you can reach it and if it is returning the right information. The curl command queries the list of providers. By default, it should only have the email/credential option.
Output:
5

Run create-next-app

This guide uses Next.js with App Router, Typescript and Tailwind CSS. If you have a different framework in mind, you can find additional guides under “Frameworks” in the sidebar. Initialize a new Next.js project with the following command and give it a name:
6

Setup environment

Create a .env file in the next app folder that you just created and paste the values below. This will make the Next app that we just created use the local Nile Postgres and Nile Auth.
7

Install dependencies

8
Your application must expose API routes to handle authentication operations.Create a folder called api under the app folder and a folder called [...nile] under it:
Create following files handle the calls to your server, as well as expose the nile instance to your application:
app/api/[...nile]/nile.ts
app/api/[...nile]/route.ts
9

Use SDK Components

Your application will interact with above authentication routes using SDK components. Replace the boilerplate app/page.tsx with the following:/app/page.jsx
10

Run and Log in to your application

Navigate to localhost to see the page. You should see a signup form that looks like this:Signup FormEnter a dummy email and password into the SignUpForm.If all went well, you will be logged in automatically and see the user profile and an organization switcher that allows you to create new organizations and switch between them:User profile and organization switcher