@banata-auth/nextjs
v0.2.5
Published
Next.js integration for Banata Auth — route handler, middleware, and server-side utilities
Downloads
626
Maintainers
Readme
@banata-auth/nextjs
Next.js helpers for Banata Auth.
Use this package when your app needs to:
- proxy
/api/auth/*requests to a Banata instance - keep auth cookies on your own domain
- bind auth flows to a Banata project with a server-side API key
- read auth state in server components and server actions
Installation
npm install @banata-auth/nextjsRecommended Setup
// src/lib/auth-server.ts
import { createBanataAuthServer } from "@banata-auth/nextjs/server";
export const {
handler,
isAuthenticated,
getToken,
preloadAuthQuery,
fetchAuthQuery,
fetchAuthMutation,
fetchAuthAction,
} = createBanataAuthServer({
apiKey: process.env.BANATA_API_KEY!,
});Hosted Banata apps default to https://auth.banata.dev. Only set authUrl if you use a custom Banata auth domain or a self-hosted deployment:
createBanataAuthServer({
apiKey: process.env.BANATA_API_KEY!,
authUrl: process.env.BANATA_AUTH_URL,
});// src/app/api/auth/[...all]/route.ts
import { handler } from "@/lib/auth-server";
export const { GET, POST, PUT, PATCH, DELETE } = handler;Note
This package is the normal app-side integration for hosted or self-hosted Banata. Self-hosting does not change the app contract: developers still create a project in the Banata dashboard and bind their app with a project-scoped API key.
