{"_id":"@bolkauth/nextjs","_rev":"3-1744db87b88092b439bbe3d4783e5bd4","name":"@bolkauth/nextjs","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@bolkauth/nextjs","version":"0.1.0","license":"MIT","_id":"@bolkauth/nextjs@0.1.0","maintainers":[{"name":"shreyvats01","email":"techtechnicalshrey@gmail.com"}],"homepage":"https://github.com/shrey/clerk#readme","bugs":{"url":"https://github.com/shrey/clerk/issues"},"dist":{"shasum":"5c03874fcdce67dbc8bed89b7392288c27686008","tarball":"https://registry.npmjs.org/@bolkauth/nextjs/-/nextjs-0.1.0.tgz","fileCount":13,"integrity":"sha512-zv5JlqgvZxyv+LOBpzHo45jpiJi0X7lU4Dbb3Ro0QPyGQ3KiIO94t7844E+gq0x9Rquu2XDGGCneDzTTNfxNpg==","signatures":[{"sig":"MEYCIQCOroVkuihNWplEdWlvn8zyjZxSUZtoJFh3l1amuKXHUgIhANl1M4sdP+1Q30a/6QtRY3D4wjIt1RdH9rYsg8awEUP/","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":17821},"main":"./dist/index.js","_from":"file:bolkauth-nextjs-0.1.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"dev":"tsup --watch","build":"tsup"},"_npmUser":{"name":"shreyvats01","email":"techtechnicalshrey@gmail.com"},"_resolved":"/tmp/4152092901b5df6deb8dd8caa8c48fe8/bolkauth-nextjs-0.1.0.tgz","_integrity":"sha512-zv5JlqgvZxyv+LOBpzHo45jpiJi0X7lU4Dbb3Ro0QPyGQ3KiIO94t7844E+gq0x9Rquu2XDGGCneDzTTNfxNpg==","repository":{"url":"git+https://github.com/shrey/clerk.git","type":"git"},"_npmVersion":"10.8.2","description":"Next.js App Router handlers and middleware for BolkAuth","directories":{},"_nodeVersion":"20.20.2","dependencies":{"@bolkauth/core":"0.1.0","@bolkauth/react":"0.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.3.3"},"peerDependencies":{"next":">=13","react":">=18","react-dom":">=18"},"_npmOperationalInternal":{"tmp":"tmp/nextjs_0.1.0_1785510663435_0.6949279672863042","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@bolkauth/nextjs","version":"0.1.1","license":"MIT","_id":"@bolkauth/nextjs@0.1.1","maintainers":[{"name":"shreyvats01","email":"techtechnicalshrey@gmail.com"}],"homepage":"https://github.com/shrey/clerk#readme","bugs":{"url":"https://github.com/shrey/clerk/issues"},"dist":{"shasum":"18b873c74484e276ab5e6dc21d38e50ed6aab8df","tarball":"https://registry.npmjs.org/@bolkauth/nextjs/-/nextjs-0.1.1.tgz","fileCount":14,"integrity":"sha512-cexZdSsig3sQUahbbVipWU9bcEPBAZ5BkA5lkWXPeDq2S7IkBD3WPRnyM6sZ03i2qFWJBwJayZgZ9y5Qg5AmXQ==","signatures":[{"sig":"MEYCIQCLXPlPrDBwMXznkmEzp8iID5H2UQasgV+fwAwoKkV7QQIhALQxvtClz+oJSliF6TO+lEs7BnRZpbyhm7JaRQ7O0oo/","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":17944},"main":"./dist/index.js","_from":"file:bolkauth-nextjs-0.1.1.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"dev":"tsup --watch","build":"tsup"},"_npmUser":{"name":"shreyvats01","email":"techtechnicalshrey@gmail.com"},"_resolved":"/tmp/5e294c0ce77effca01726388807dae79/bolkauth-nextjs-0.1.1.tgz","_integrity":"sha512-cexZdSsig3sQUahbbVipWU9bcEPBAZ5BkA5lkWXPeDq2S7IkBD3WPRnyM6sZ03i2qFWJBwJayZgZ9y5Qg5AmXQ==","repository":{"url":"git+https://github.com/shrey/clerk.git","type":"git"},"_npmVersion":"10.8.2","description":"Next.js App Router handlers and middleware for BolkAuth","directories":{},"_nodeVersion":"20.20.2","dependencies":{"@bolkauth/core":"0.2.0","@bolkauth/react":"0.2.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.3.3"},"peerDependencies":{"next":">=13","react":">=18","react-dom":">=18"},"_npmOperationalInternal":{"tmp":"tmp/nextjs_0.1.1_1785597492367_0.0485437883565174","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@bolkauth/nextjs","version":"0.1.2","description":"Next.js App Router handlers and middleware for BolkAuth","license":"MIT","repository":{"type":"git","url":"git+https://github.com/Shreyvats01/bolkauth.git","directory":"packages/nextjs"},"publishConfig":{"access":"public"},"main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"peerDependencies":{"next":">=13","react":">=18","react-dom":">=18"},"dependencies":{"@bolkauth/core":"0.2.1","@bolkauth/react":"0.2.1"},"devDependencies":{"tsup":"^8.0.0","typescript":"^5.3.3"},"scripts":{"build":"tsup","dev":"tsup --watch"},"_id":"@bolkauth/nextjs@0.1.2","bugs":{"url":"https://github.com/Shreyvats01/bolkauth/issues"},"homepage":"https://github.com/Shreyvats01/bolkauth#readme","_integrity":"sha512-QbweG3ubXM5Y9vuHUe5xGK75S3MMumednEmedLRPkiUQw2q15jCf4xxwycVotPBYGUcr8W7NpaPGdnjLn6CrsA==","_resolved":"/tmp/658336b4d7998410f9102f0ce287c6b9/bolkauth-nextjs-0.1.2.tgz","_from":"file:bolkauth-nextjs-0.1.2.tgz","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-QbweG3ubXM5Y9vuHUe5xGK75S3MMumednEmedLRPkiUQw2q15jCf4xxwycVotPBYGUcr8W7NpaPGdnjLn6CrsA==","shasum":"2c6dd2b7a2a817496a9471f2356ee04cdf156a68","tarball":"https://registry.npmjs.org/@bolkauth/nextjs/-/nextjs-0.1.2.tgz","fileCount":15,"unpackedSize":24667,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@bolkauth%2fnextjs@0.1.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICXeBJr9yegv312TzAlVzsK8JqOck/xWYzNZRjhs1PLNAiEA2GRE4PUxZQ57HeY/MCdwXcjvoaXwk+I48MyDV7t5yvI="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:2b671e0b-bc31-42c3-85ea-42ef5e8bd9fe"}},"directories":{},"maintainers":[{"name":"shreyvats01","email":"techtechnicalshrey@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nextjs_0.1.2_1785611075253_0.5147399359635432"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-31T15:11:03.281Z","modified":"2026-08-01T19:04:35.739Z","0.1.0":"2026-07-31T15:11:03.596Z","0.1.1":"2026-08-01T15:18:12.516Z","0.1.2":"2026-08-01T19:04:35.393Z"},"bugs":{"url":"https://github.com/Shreyvats01/bolkauth/issues"},"license":"MIT","homepage":"https://github.com/Shreyvats01/bolkauth#readme","repository":{"type":"git","url":"git+https://github.com/Shreyvats01/bolkauth.git","directory":"packages/nextjs"},"description":"Next.js App Router handlers and middleware for BolkAuth","maintainers":[{"name":"shreyvats01","email":"techtechnicalshrey@gmail.com"}],"readme":"# @bolkauth/nextjs\n\n[![npm version](https://img.shields.io/npm/v/@bolkauth/nextjs.svg)](https://www.npmjs.com/package/@bolkauth/nextjs)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nSeamless Next.js App Router and Edge Middleware integration for **BolkAuth**.\n\n## Features\n\n- 🚀 **App Router Handlers**: Drop-in REST route handlers (`GET`, `POST`, `PATCH`, `DELETE`) for Next.js 13+ App Router.\n- ⚡ **Edge Middleware**: Lightweight middleware for route protection, authentication redirects, and onboarding enforcement.\n- 🔒 **Server Component Helpers**: First-class async functions (`getSession`, `getUser`, `requireAuth`) optimized for React Server Components.\n- ⚡ **Server Actions**: Full support for authenticated Server Actions with simple credentials verification and session lookup.\n- 🛡️ **Type Safe**: End-to-end TypeScript support out of the box.\n\n---\n\n## Installation\n\n```bash\nnpm install @bolkauth/nextjs @bolkauth/core\n# or\npnpm add @bolkauth/nextjs @bolkauth/core\n# or\nyarn add @bolkauth/nextjs @bolkauth/core\n```\n\n---\n\n## Quick Setup\n\n### 1. Configure BolkAuth Instance\n\nCreate your auth instance in `lib/auth.ts`:\n\n```typescript\n// lib/auth.ts\nimport { createBolkAuth } from \"@bolkauth/core\";\nimport { createDrizzleAdapter } from \"@bolkauth/adapter-drizzle\";\nimport { db } from \"@/db\";\n\nexport const auth = createBolkAuth({\n  adapter: createDrizzleAdapter(db),\n  secret: process.env.BOLKAUTH_SECRET!,\n  session: {\n    cookieName: \"bolkauth.session\",\n    expiresIn: 60 * 60 * 24 * 7, // 7 days\n  },\n});\n```\n\n### 2. Set Up App Router API Catch-All Route\n\nCreate `app/api/auth/[...bolkauth]/route.ts`:\n\n```typescript\n// app/api/auth/[...bolkauth]/route.ts\nimport { bolkAuthHandler } from \"@bolkauth/nextjs\";\nimport { auth } from \"@/lib/auth\";\n\nexport const { GET, POST, PATCH, DELETE } = bolkAuthHandler(auth);\n```\n\n---\n\n## Edge Middleware\n\nProtect private routes and automatically handle redirects for unauthenticated users or incomplete onboarding flows.\n\n```typescript\n// middleware.ts\nimport { bolkAuthMiddleware } from \"@bolkauth/nextjs\";\nimport { auth } from \"@/lib/auth\";\n\nexport default bolkAuthMiddleware(auth, {\n  signInUrl: \"/sign-in\",\n  onboardingUrl: \"/onboarding\",\n  publicRoutes: [\"/\", \"/sign-in\", \"/sign-up\", \"/api/auth\"],\n});\n\nexport const config = {\n  matcher: [\"/((?!_next/static|_next/image|favicon.ico|.*\\\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)\"],\n};\n```\n\n### Middleware Options\n\n| Parameter | Type | Default | Description |\n| :--- | :--- | :--- | :--- |\n| `signInUrl` | `string` | `\"/sign-in\"` | URL path to redirect unauthenticated requests. |\n| `onboardingUrl` | `string` | `\"/onboarding\"` | URL path to redirect users who haven't completed onboarding. |\n| `publicRoutes` | `string[]` | `[]` | Array of path prefixes that bypass authentication checks. |\n\n---\n\n## Server Components Integration\n\n`@bolkauth/nextjs` provides flexible helpers for reading session data and enforcing auth in React Server Components (`RSC`).\n\n### Using `createServerHelpers`\n\n```typescript\n// app/dashboard/page.tsx\nimport { createServerHelpers } from \"@bolkauth/nextjs\";\nimport { auth } from \"@/lib/auth\";\n\nconst { getSession, getUser, requireAuth } = createServerHelpers(auth);\n\nexport default async function DashboardPage() {\n  // Requires authentication; automatically redirects to /sign-in if unauthorized\n  const user = await requireAuth();\n\n  return (\n    <main className=\"p-8\">\n      <h1 className=\"text-2xl font-bold\">Welcome back, {user.name || user.email}!</h1>\n      <p className=\"text-gray-600\">User ID: {user.id}</p>\n    </main>\n  );\n}\n```\n\n### Direct Helper Imports\n\n```typescript\nimport { getSession, getUser, requireAuth } from \"@bolkauth/nextjs\";\n\nexport default async function ProfilePage() {\n  const user = await requireAuth();\n  return <div>Profile for {user.email}</div>;\n}\n```\n\n---\n\n## Server Actions Integration\n\nAuthenticate user requests seamlessly inside Next.js Server Actions:\n\n```typescript\n// app/actions/profile.ts\n\"use server\";\n\nimport { createServerHelpers } from \"@bolkauth/nextjs\";\nimport { auth } from \"@/lib/auth\";\nimport { revalidatePath } from \"next/cache\";\n\nconst { requireAuth } = createServerHelpers(auth);\n\nexport async function updateDisplayName(formData: FormData) {\n  const user = await requireAuth();\n  const newName = formData.get(\"name\") as string;\n\n  if (!newName) {\n    throw new Error(\"Name is required\");\n  }\n\n  await auth.config.adapter.updateUser(user.id, { name: newName });\n  revalidatePath(\"/dashboard\");\n}\n```\n\n---\n\n## API Reference\n\n### Exported Modules\n\n- `bolkAuthHandler(authInstance)`: Returns route handler functions (`GET`, `POST`, `PATCH`, `DELETE`). Alias: `authFlowHandler`.\n- `bolkAuthMiddleware(authInstance, options)`: Creates an Edge Middleware handler. Alias: `authFlowMiddleware`.\n- `createServerHelpers(authInstance)`: Binds a BolkAuth instance to Next.js cookie store and returns `{ getSession, getUser, requireAuth }`.\n- `getSession()`: Returns the active session object parsed from Next.js cookie store.\n- `getUser()`: Resolves the current user.\n- `requireAuth(signInUrl?: string)`: Protects a route/server action, redirecting if unauthenticated.\n\n---\n\n## License\n\n[MIT](./LICENSE) © BolkAuth\n","readmeFilename":"README.md"}