@zautha/nextjs
v0.14.0
Published
Zautha for Next.js (App Router): proxy, auth() and currentUser() on the server, React components on the client.
Readme
@zautha/nextjs
Zautha for Next.js 16 (App Router): know who is signed in during server rendering, in route handlers and in server actions, and use the prebuilt React components on the client.
Install
npm i @zautha/nextjs @zautha/ui.env.local (both keys are on your instance's API keys page in the dashboard):
NEXT_PUBLIC_ZAUTHA_PUBLISHABLE_KEY=pk_test_...
ZAUTHA_SECRET_KEY=sk_test_...proxy.ts
import { createRouteMatcher, zauthaProxy } from "@zautha/nextjs/server";
const isProtected = createRouteMatcher(["/dashboard(.*)"]);
export default zauthaProxy(async (auth, req) => {
if (isProtected(req)) await auth.protect();
});
export const config = { matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"] };auth.protect() redirects a signed-out page load to sign-in and answers other requests with 401.
Documentation
Everything else (the full API, guides and examples) is at https://zautha.com/docs/sdk/nextjs/.
License
MIT, see LICENSE.
