Next.js Quickstart
Auth, permissions, and the gateway in your scaffolded Next.js 16 app.
There is no separate Nebutra product to integrate with — create-sailor generates apps/web, a
Next.js 16 App Router project, as your app. This page shows the pieces already wired into it.
Scaffold the project
npx create-sailor my-app
cd my-app
pnpm install
pnpm devpnpm dev starts a zero-key preview (local PGlite database, demo sign-in
admin@example.com / preview-demo) at localhost:3001, with the marketing site at
localhost:3000. See Installation.
Read the current session in a Server Component
Better Auth is the only auth provider (no Clerk/NextAuth/Supabase adapters — ADR 2026-09-24). Server Components read the session directly:
import { redirect } from "next/navigation";
import { auth } from "@/lib/auth"; // your project's Better Auth instance
import { headers } from "next/headers";
export default async function DashboardPage() {
const session = await auth.api.getSession({ headers: await headers() });
if (!session) {
redirect("/sign-in");
}
return <h1>Welcome, {session.user.name}</h1>;
}Gate UI and actions with permissions
@nebutra/permissions wraps CASL for in-process RBAC/ABAC checks:
import { Can } from "@nebutra/permissions/react";
<Can action="delete" resource="Project" subject={project}>
<DeleteButton />
</Can>"use server";
import { requirePermission } from "@nebutra/permissions";
export async function deleteProject(projectId: string) {
await requirePermission("delete", "Project"); // throws 403 if the caller lacks the scope
// ...
}Call the gateway
Business endpoints live in backends/gateway (Hono), mounted in-process at
app/api/[[...route]] by default (GATEWAY_MODE=embedded). Call it like any same-origin API
route:
const res = await fetch("/api/v1/ai/models");Add a new endpoint with the CLI rather than a Next route handler — apps/web route handlers are
frozen to what's intrinsically Next (auth callbacks, OG routes):
nebutra generate route projectsNext steps
How is this guide?
Last updated on