- Install the Basic Next.js SDK into an existing Next.js project
- Connect to a Basic project and customize the schema
- 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 Replace
basic.config.ts in the root of your project:basic.config.ts
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
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:Clicking the sign in button will redirect to the Basic.id login page. After signing in, users are redirected back to your app.
app/page.tsx
Important: Import Patterns
| File Type | Import From |
|---|---|
Client components ('use client') | @basictech/nextjs/client or @basictech/react |
| Server components / middleware | @basictech/nextjs |
Using the Database
Once authenticated, you can use the database in your client components:app/components/TodoList.tsx
Next Steps
- Database Modes - Learn about sync vs remote mode
- Middleware - Protect routes with authentication
- Database Methods - Full database API reference

