docs / sdks/nextjs
Next.js SDK
Components and server-side adapters for Next.js 16 applications.
What it includes
- All five public React authentication components.
- A same-origin proxy route for secure mutations and session cookies.
- OAuth callback handling for Google and GitHub.
- Middleware helpers for protected routes and session refresh.
- Server helpers for authenticated Server Components and actions.
Server helpers
| Helper | Returns |
|---|---|
| auth() | The current session, claims, user, and authentication state. |
| currentUser() | The current user or null. |
| requireAuth() | The authenticated session or a redirect to sign-in. |
import { requireAuth } from "@vulyo/nextjs/server";export default async function AccountPage() { const { user } = await requireAuth(); return <h1>Welcome, {user.displayName ?? user.email}</h1>;}Protect routes
import { vulyoMiddleware } from "@vulyo/nextjs/middleware";export default vulyoMiddleware({ publicRoutes: ["/", "/sign-in", "/sign-up"],});export const config = { matcher: ["/((?!_next|.*\\..*).*)"],};The middleware validates the access token, refreshes an eligible session, and redirects unauthenticated requests to your sign-in page.