Skip to main content
In this guide, you will:
  1. Install the Basic Next.js SDK into an existing Next.js project
  2. Connect to a Basic project and customize the schema
  3. Add sign in and sign out functionality
This library is for Next.js applications using the App Router. For plain React apps, see the @basictech/react documentation.

Installation

1

Install the @basictech/nextjs library

Navigate to your project and install the Basic Next.js SDK:
Terminal

Set up basic.config

1

Create a basic.config.ts file

Create a new file called basic.config.ts in the root of your project:
basic.config.ts
Replace YOUR_PROJECT_ID with your Project ID from the Basic dashboard.

Create a Client Provider

1

Create a providers file

Create app/providers.tsx to wrap your app with BasicProvider:
app/providers.tsx
The 'use client' directive is required because BasicProvider uses React context and hooks.
2

Add to your layout

Update app/layout.tsx to use the providers:
app/layout.tsx

Adding Authentication

1

Create a client component with auth

Create a component to handle authentication. This must be a client component:
app/components/AuthButton.tsx
2

Use in your page

Add the auth component to your page:
app/page.tsx
Clicking the sign in button will redirect to the Basic.id login page. After signing in, users are redirected back to your app.

Important: Import Patterns

Due to Next.js SSR, you must use the correct import paths to avoid “self is not defined” errors.

Using the Database

Once authenticated, you can use the database in your client components:
app/components/TodoList.tsx

Next Steps