The Nile-JS SDK is a toolkit for building multi-tenant applications with React, Next.js, Remix, Express, and more. The React and web components are documented under components. This reference is for the server-side SDK, which is used to build your server-side application logic.

Installation

npm install @niledatabase/server 

Configuration

The SDK is configured using environment variables. You can get these from the Nile Console:

1

Obtain Database Credentials

  1. If you haven’t signed up for Nile yet, sign up here and follow the steps to create a database.
  2. Navigate to Database Settings in your database’s UI at console.thenile.dev.
  3. Go to Connection settings.
  4. Select the CLI icon, and click Generate credentials
  5. Copy the required credentials and store them in an .env file so they can be used in the application to connect to the Nile auth service.
    NILEDB_USER=niledb_user
    NILEDB_PASSWORD=niledb_password
    NILEDB_API_URL=https://us-west-2.api.thenile.dev/v2/databases/<database_id>
    NILEDB_POSTGRES_URL=postgres://us-west-2.db.thenile.dev:5432/<database_name>
    

Initializing the SDK

The SDK is initialized using the Nile class. If you initialize the SDK without any arguments, it will use the configuration in the .env file. You can also pass in a configuration object to the Nile constructor to override the configuration in the .env file. For more information about the available configuration options, see configuration.

The Nile object is a singleton. Initializing it multiple times in the same application will return the same instance.
import { Nile } from "@niledatabase/server";

const nile = await Nile();

Available Modules

The SDK provides a number of modules with methods for interacting with Nile:

API Reference

The API reference is available in the API Reference section.

Was this page helpful?