@squadbase/nextjs
v0.0.2
Published
Next.js SDK for Squadbase - A package for handling server-side operations in Squadbase applications with Next.js.
Downloads
33
Readme
@squadbase/nextjs
Next.js SDK for Squadbase - A package for handling server-side operations in Squadbase applications with Next.js.
Installation
npm install @squadbase/nextjs
# or
yarn add @squadbase/nextjs
# or
pnpm add @squadbase/nextjsFeatures
User Session
import { createNextjsServerClient } from "@squadbase/nextjs";
// In your Next.js server component or API route
const client = createNextjsServerClient({
projectId: "your-project-id",
});
// Get the current authenticated user
const user = await client.getUser();
console.log(user);
// {
// username: string,
// email: string,
// firstName: string,
// lastName: string,
// iconUrl: string | null,
// roles: string[]
// }Local Development
For local development, you can provide a mock user:
const client = createNextjsServerClient({
projectId: "your-project-id",
mockUser: {
username: "test-user",
email: "[email protected]",
firstName: "Test",
lastName: "User",
iconUrl: null,
roles: ["user"],
},
});API Reference
createNextjsServerClient(options: NextjsServerClientOptions)
Creates a new Next.js server client instance. This is a wrapper around createServerClient that automatically handles cookie management using Next.js's cookies() API.
Options
projectId(string): Your Squadbase project IDmockUser(optional): Mock user object for local development
ServerClient
This package re-exports all types and interfaces from @squadbase/server. See the @squadbase/server documentation for more details.
License
MIT
