{"_id":"@api-buddy/nextauth","_rev":"6-722c7aa85a84990ffa7d2a6439f4e3d7","name":"@api-buddy/nextauth","dist-tags":{"latest":"2.0.0"},"versions":{"0.0.5":{"name":"@api-buddy/nextauth","version":"0.0.5","_id":"@api-buddy/nextauth@0.0.5","maintainers":[{"name":"iamtomhanks","email":"brechanson@gmail.com"}],"homepage":"https://github.com/api-buddy/api-buddy#readme","bugs":{"url":"https://github.com/api-buddy/api-buddy/issues"},"bin":{"api-buddy-nextauth":"cli.cjs"},"dist":{"shasum":"b40fce0f8ff948c2de2d4dd77fced0d60a4d501a","tarball":"https://registry.npmjs.org/@api-buddy/nextauth/-/nextauth-0.0.5.tgz","fileCount":27,"integrity":"sha512-Cb5gerLz7MT3qNWpnR1LpzAmGvluAultLYFIZprJxz14MYMtdDFxJJ1CA/2CghvHy9K+0tEejGbsbZ+4ncjETg==","signatures":[{"sig":"MEUCIQC3mIxjuXtgOm+/WRSar1ViQwkoTfQFoIUYM2eYrUy5wAIgGPnK7W5eIqDxfqTCiAlVekn0n3bjMLHeaNWilV/R8NI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24259},"main":"dist/index.js","_from":"file:api-buddy-nextauth-0.0.5.tgz","types":"dist/index.d.ts","scripts":{"dev":"tsup src/index.ts --format esm,cjs --dts --watch --external react,next","build":"tsup src/index.ts --format esm,cjs --dts --external react,next","clean":"rm -rf dist"},"_npmUser":{"name":"iamtomhanks","email":"brechanson@gmail.com"},"_resolved":"/private/var/folders/w3/00m0j5k95zjfx4vwz3csj_vc0000gn/T/3dc0f55f019aa3bf5f0cedae10d9bff6/api-buddy-nextauth-0.0.5.tgz","_integrity":"sha512-Cb5gerLz7MT3qNWpnR1LpzAmGvluAultLYFIZprJxz14MYMtdDFxJJ1CA/2CghvHy9K+0tEejGbsbZ+4ncjETg==","repository":{"url":"git+https://github.com/api-buddy/api-buddy.git","type":"git","directory":"packages/auth/nextauth"},"_npmVersion":"9.8.1","description":"API Buddy integration for NextAuth.js (Auth.js)","directories":{},"_nodeVersion":"18.18.0","dependencies":{"@api-buddy/core":"^0.0.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.0.0","@types/node":"^20.0.0","@types/react":"^18.0.0","@types/react-dom":"^18.0.0"},"peerDependencies":{"next":">=14.0.0","react":">=18.0.0","next-auth":"^4.24.5"},"_npmOperationalInternal":{"tmp":"tmp/nextauth_0.0.5_1749533775239_0.6479988418387399","host":"s3://npm-registry-packages-npm-production"}},"0.0.8":{"name":"@api-buddy/nextauth","version":"0.0.8","_id":"@api-buddy/nextauth@0.0.8","maintainers":[{"name":"iamtomhanks","email":"brechanson@gmail.com"}],"homepage":"https://github.com/api-buddy/api-buddy#readme","bugs":{"url":"https://github.com/api-buddy/api-buddy/issues"},"bin":{"api-buddy-nextauth":"cli.cjs"},"dist":{"shasum":"d38e86bab5344a9a3f78af12c486f5aa3b99d55e","tarball":"https://registry.npmjs.org/@api-buddy/nextauth/-/nextauth-0.0.8.tgz","fileCount":27,"integrity":"sha512-Mmyu9juMnr8lsh5OljRMwidDk/s5j40d/pCsGpyJriHz9lOVaEhaqD2MPRnEjXpxozH7H7mlTuFmA8wsGNtI2A==","signatures":[{"sig":"MEYCIQDhoFf1sBNukyduEWFpuVbwJ5eVOR9kMHgP5ylmRARAfwIhALHLgIdpjpQq09EkdoYB1qO42wjpKTlEv+wo0pLe2D8s","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24374},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"dev":"tsup src/index.ts --format esm,cjs --dts --watch --external react,next","build":"echo Skipping build as it was already done","clean":"rm -rf dist","prepare":"echo Skipping build as it was already done","prepublishOnly":"echo Skipping prepublish as it was already done"},"_npmUser":{"name":"iamtomhanks","email":"brechanson@gmail.com"},"repository":{"url":"git+https://github.com/api-buddy/api-buddy.git","type":"git","directory":"packages/auth/nextauth"},"_npmVersion":"9.8.1","description":"API Buddy integration for NextAuth.js (Auth.js)","directories":{},"_nodeVersion":"18.18.0","dependencies":{"@api-buddy/core":"^0.0.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.0.0","@types/node":"^20.0.0","@types/react":"^18.0.0","@types/react-dom":"^18.0.0"},"peerDependencies":{"next":">=14.0.0","react":">=18.0.0","next-auth":"^4.24.5"},"_npmOperationalInternal":{"tmp":"tmp/nextauth_0.0.8_1749534154787_0.5236228961213771","host":"s3://npm-registry-packages-npm-production"}},"0.0.9":{"name":"@api-buddy/nextauth","version":"0.0.9","_id":"@api-buddy/nextauth@0.0.9","maintainers":[{"name":"iamtomhanks","email":"brechanson@gmail.com"}],"homepage":"https://github.com/api-buddy/api-buddy#readme","bugs":{"url":"https://github.com/api-buddy/api-buddy/issues"},"bin":{"api-buddy-nextauth":"cli.cjs"},"dist":{"shasum":"6a7ee19800c1d8d0c43cfa7d138d8ec559b96c44","tarball":"https://registry.npmjs.org/@api-buddy/nextauth/-/nextauth-0.0.9.tgz","fileCount":27,"integrity":"sha512-8rXa1IlOr1kL5YD2EZOzpEaATMw9CenbM/wrN5czvBLqmCfDb5OnOfF/L5GB0maBaglwL/CDaPUQlj8B8pkyRg==","signatures":[{"sig":"MEUCIDuApPjOxoFxB35LHLp6ADa/A4+z754u4m4S8cZ6S4f6AiEAvab2fiRze7xX0pyVoyxpUZSsEmsA93IYQNH0sA7aKqI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24374},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"dev":"tsup src/index.ts --format esm,cjs --dts --watch --external react,next","build":"echo Skipping build as it was already done","clean":"rm -rf dist","prepare":"echo Skipping build as it was already done","prepublishOnly":"echo Skipping prepublish as it was already done"},"_npmUser":{"name":"iamtomhanks","email":"brechanson@gmail.com"},"repository":{"url":"git+https://github.com/api-buddy/api-buddy.git","type":"git","directory":"packages/auth/nextauth"},"_npmVersion":"9.8.1","description":"API Buddy integration for NextAuth.js (Auth.js)","directories":{},"_nodeVersion":"18.18.0","dependencies":{"@api-buddy/core":"^0.0.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.0.0","@types/node":"^20.0.0","@types/react":"^18.0.0","@types/react-dom":"^18.0.0"},"peerDependencies":{"next":">=14.0.0","react":">=18.0.0","next-auth":"^4.24.5"},"_npmOperationalInternal":{"tmp":"tmp/nextauth_0.0.9_1749534272620_0.28623165374027226","host":"s3://npm-registry-packages-npm-production"}},"0.4.108":{"name":"@api-buddy/nextauth","version":"0.4.108","_id":"@api-buddy/nextauth@0.4.108","maintainers":[{"name":"iamtomhanks","email":"brechanson@gmail.com"}],"homepage":"https://github.com/api-buddy/api-buddy#readme","bugs":{"url":"https://github.com/api-buddy/api-buddy/issues"},"bin":{"api-buddy-nextauth":"cli.cjs"},"dist":{"shasum":"049eace0ff2f24a48c17455ba76bca9258bebaa5","tarball":"https://registry.npmjs.org/@api-buddy/nextauth/-/nextauth-0.4.108.tgz","fileCount":27,"integrity":"sha512-bYV6Hi4zTAUSMVf9fkHmQZ2ZD2/RPJYWckD6PS/4AYhey50QffCc3mvDxtIzL8QYJ+h++RrUMEGsRfqMeFqg3g==","signatures":[{"sig":"MEUCIQD/nsbIKnmwB4/btYpEKihd8Y/hR3PayFg/u6Fyq8+DUwIgOHnGJkIAu/mxfpZThSrIL+GSGnGc9SjDL8WBb3ZoUlk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24323},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"ce0089122abaa9fcfc04053fc31cd6afd64b01f7","scripts":{"dev":"tsup src/index.ts --format esm,cjs --dts --watch --external react,next","build":"tsup src/index.ts --format esm,cjs --dts --external react,next","clean":"rm -rf dist","prepublishOnly":"npm run build"},"_npmUser":{"name":"iamtomhanks","email":"brechanson@gmail.com"},"repository":{"url":"git+https://github.com/api-buddy/api-buddy.git","type":"git","directory":"packages/auth/nextauth"},"_npmVersion":"9.8.1","description":"API Buddy integration for NextAuth.js (Auth.js)","directories":{},"_nodeVersion":"18.18.0","dependencies":{"@api-buddy/core":"^0.4.108"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.0.0","@types/node":"^20.0.0","@types/react":"^18.0.0","@types/react-dom":"^18.0.0"},"peerDependencies":{"next":">=14.0.0","react":">=18.0.0","next-auth":"^4.24.5"},"_npmOperationalInternal":{"tmp":"tmp/nextauth_0.4.108_1749659722505_0.049094829694263264","host":"s3://npm-registry-packages-npm-production"}},"1.0.0":{"name":"@api-buddy/nextauth","version":"1.0.0","_id":"@api-buddy/nextauth@1.0.0","maintainers":[{"name":"iamtomhanks","email":"brechanson@gmail.com"}],"homepage":"https://github.com/api-buddy/api-buddy#readme","bugs":{"url":"https://github.com/api-buddy/api-buddy/issues"},"bin":{"api-buddy-nextauth":"cli.cjs"},"dist":{"shasum":"c2c4488a759240827eac964fbc4e38ae40586198","tarball":"https://registry.npmjs.org/@api-buddy/nextauth/-/nextauth-1.0.0.tgz","fileCount":25,"integrity":"sha512-h4/DzCl6HMOmWbX/6hY4HEAFlPJ/1CXHf9Y8YWd7tRweVO+3941LAQShM4lL+N7ylgV2+pqM0K2riWtJYVXl9w==","signatures":[{"sig":"MEYCIQCujELbU1hgfSESA7IbktLcNxenNUg9tKIloXn4Iip54gIhAOcZWcfGBBBfoPrUwyKejYcNuCNvnR3grGiF8bIinypa","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":23255},"main":"dist/index.js","_from":"file:api-buddy-nextauth-1.0.0.tgz","types":"dist/index.d.ts","scripts":{"dev":"tsup --watch","lint":"eslint src --ext .ts,.tsx","test":"jest","build":"pnpm clean && tsup","clean":"rimraf dist","format":"prettier --write \"src/**/*.{ts,tsx}\"","prebuild":"node -e \"const { execSync } = require('child_process'); const path = require('path'); const fs = require('fs'); let root = process.cwd(); while (root !== '/' && !fs.existsSync(path.join(root, 'pnpm-workspace.yaml'))) { root = path.dirname(root); } if (root === '/') { console.error('❌ Could not find project root directory'); process.exit(1); } require(path.join(root, 'scripts/ensure-tsup-config.js'));\"","type-check":"tsc --noEmit"},"_npmUser":{"name":"iamtomhanks","email":"brechanson@gmail.com"},"_resolved":"/private/var/folders/w3/00m0j5k95zjfx4vwz3csj_vc0000gn/T/d2d15a9c198e42e1c969d574c41a93a0/api-buddy-nextauth-1.0.0.tgz","_integrity":"sha512-h4/DzCl6HMOmWbX/6hY4HEAFlPJ/1CXHf9Y8YWd7tRweVO+3941LAQShM4lL+N7ylgV2+pqM0K2riWtJYVXl9w==","repository":{"url":"git+https://github.com/api-buddy/api-buddy.git","type":"git","directory":"packages/auth/nextauth"},"_npmVersion":"9.8.1","description":"API Buddy integration for NextAuth.js (Auth.js)","directories":{},"_nodeVersion":"18.18.0","dependencies":{"@api-buddy/plugin-core":"1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","rimraf":"^5.0.5","typescript":"^5.0.0","@types/node":"^20.0.0","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@api-buddy/tsup-config":"1.0.0"},"peerDependencies":{"next":">=14.0.0","react":">=18.0.0","next-auth":"^4.24.5"},"_npmOperationalInternal":{"tmp":"tmp/nextauth_1.0.0_1750087967448_0.4441706644498975","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@api-buddy/nextauth","version":"2.0.0","description":"API Buddy integration for NextAuth.js (Auth.js)","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/api-buddy/api-buddy.git","directory":"packages/auth/nextauth"},"peerDependencies":{"react":">=18.0.0","next":">=14.0.0","next-auth":"^4.24.5"},"dependencies":{"@api-buddy/plugin-core":"2.0.0"},"devDependencies":{"@types/node":"^20.0.0","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","tsup":"^8.0.0","typescript":"^5.0.0","rimraf":"^5.0.5","@api-buddy/tsup-config":"2.0.0"},"bin":{"api-buddy-nextauth":"cli.cjs"},"publishConfig":{"access":"public"},"scripts":{"build":"pnpm clean && tsup","dev":"tsup --watch","clean":"rimraf dist","test":"jest","lint":"eslint src --ext .ts,.tsx","type-check":"tsc --noEmit","format":"prettier --write \"src/**/*.{ts,tsx}\"","prebuild":"node -e \"const { execSync } = require('child_process'); const path = require('path'); const fs = require('fs'); let root = process.cwd(); while (root !== '/' && !fs.existsSync(path.join(root, 'pnpm-workspace.yaml'))) { root = path.dirname(root); } if (root === '/') { console.error('❌ Could not find project root directory'); process.exit(1); } require(path.join(root, 'scripts/ensure-tsup-config.js'));\""},"bugs":{"url":"https://github.com/api-buddy/api-buddy/issues"},"homepage":"https://github.com/api-buddy/api-buddy#readme","_id":"@api-buddy/nextauth@2.0.0","_integrity":"sha512-xYJA0tHNFIQK1mR6PSp6OFM1At29Vt7tU8DgyHyLgtCqv5CvXJfwv9gqpvbys3/e1IF/3JmNJo1e5UkiK1rftw==","_resolved":"/private/var/folders/w3/00m0j5k95zjfx4vwz3csj_vc0000gn/T/d4761a3b826873f8449c3a55047e9a4f/api-buddy-nextauth-2.0.0.tgz","_from":"file:api-buddy-nextauth-2.0.0.tgz","_nodeVersion":"18.18.0","_npmVersion":"9.8.1","dist":{"integrity":"sha512-xYJA0tHNFIQK1mR6PSp6OFM1At29Vt7tU8DgyHyLgtCqv5CvXJfwv9gqpvbys3/e1IF/3JmNJo1e5UkiK1rftw==","shasum":"20b3500803e077823080f7009d1d4c0eb0ab9655","tarball":"https://registry.npmjs.org/@api-buddy/nextauth/-/nextauth-2.0.0.tgz","fileCount":25,"unpackedSize":23255,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCpsolQ2wxuRWlEz/puonAvOQwORag4uK40AZnfH9lAogIgQzKex6pBF0GeCCJ10ldioHXYE/kaZuuA3S4VBKMybqE="}]},"_npmUser":{"name":"iamtomhanks","email":"brechanson@gmail.com"},"directories":{},"maintainers":[{"name":"iamtomhanks","email":"brechanson@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nextauth_2.0.0_1750103121528_0.7223934210684573"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-10T05:36:14.791Z","modified":"2025-06-16T19:45:21.884Z","0.0.5":"2025-06-10T05:36:15.414Z","0.0.8":"2025-06-10T05:42:34.991Z","0.0.9":"2025-06-10T05:44:32.822Z","0.4.108":"2025-06-11T16:35:22.711Z","1.0.0":"2025-06-16T15:32:48.350Z","2.0.0":"2025-06-16T19:45:21.691Z"},"bugs":{"url":"https://github.com/api-buddy/api-buddy/issues"},"homepage":"https://github.com/api-buddy/api-buddy#readme","repository":{"type":"git","url":"git+https://github.com/api-buddy/api-buddy.git","directory":"packages/auth/nextauth"},"description":"API Buddy integration for NextAuth.js (Auth.js)","maintainers":[{"name":"iamtomhanks","email":"brechanson@gmail.com"}],"readme":"# @api-buddy/nextauth\r\n\r\nAPI Buddy integration for NextAuth.js (Auth.js) - A complete authentication solution for Next.js applications.\r\n\r\n## Features\r\n\r\n- Easy setup with a single command\r\n- TypeScript support out of the box\r\n- Built-in session management\r\n- Support for multiple authentication providers\r\n- Secure JWT and database session strategies\r\n- Middleware for protecting routes\r\n\r\n## Installation\r\n\r\n```bash\r\n# Using npm\r\nnpm install @api-buddy/nextauth next-auth\r\n\r\n# Using yarn\r\nyarn add @api-buddy/nextauth next-auth\r\n\r\n# Using pnpm\r\npnpm add @api-buddy/nextauth next-auth\r\n```\r\n\r\n## Quick Start\r\n\r\n1. Run the setup command:\r\n   ```bash\r\n   npx @api-buddy/nextauth\r\n   ```\r\n   This will:\r\n   - Create the necessary API routes\r\n   - Set up the authentication configuration\r\n   - Install required dependencies\r\n   - Configure environment variables\r\n\r\n2. Update your `.env.local` with your authentication providers' credentials:\r\n   ```env\r\n   NEXTAUTH_SECRET=your-secret-here\r\n   NEXTAUTH_URL=http://localhost:3000\r\n   \r\n   # Example: Google OAuth\r\n   GOOGLE_CLIENT_ID=your-google-client-id\r\n   GOOGLE_CLIENT_SECRET=your-google-client-secret\r\n   ```\r\n\r\n3. Wrap your application with the `NextAuthProvider` in your root layout:\r\n   ```tsx\r\n   // app/layout.tsx\r\n   'use client';\r\n   \r\n   import { NextAuthProvider } from '@api-buddy/nextauth';\r\n   \r\n   export default function RootLayout({\r\n     children,\r\n   }: {\r\n     children: React.ReactNode;\r\n   }) {\r\n     return (\r\n       <html lang=\"en\">\r\n         <body>\r\n           <NextAuthProvider>\r\n             {children}\r\n           </NextAuthProvider>\r\n         </body>\r\n       </html>\r\n     );\r\n   }\r\n   ```\r\n\r\n## Usage\r\n\r\n### Protecting Pages\r\n\r\nUse the `useSession` hook to check the authentication status:\r\n\r\n```tsx\r\n'use client';\r\n\r\nimport { useSession } from '@api-buddy/nextauth';\r\n\r\nexport default function Profile() {\r\n  const { data: session } = useSession();\r\n  \r\n  if (!session) {\r\n    return <div>Please sign in to view this page</div>;\r\n  }\r\n  \r\n  return (\r\n    <div>\r\n      <h1>Welcome, {session.user?.name}!</h1>\r\n      <p>Email: {session.user?.email}</p>\r\n    </div>\r\n  );\r\n}\r\n```\r\n\r\n### Server Components\r\n\r\nFor server components, use the `getServerSession` function:\r\n\r\n```tsx\r\nimport { getServerSession } from 'next-auth';\r\nimport { authOptions } from '@/lib/auth';\r\n\r\nexport default async function ProfilePage() {\r\n  const session = await getServerSession(authOptions);\r\n  \r\n  if (!session) {\r\n    return <div>Please sign in to view this page</div>;\r\n  }\r\n  \r\n  return (\r\n    <div>\r\n      <h1>Welcome, {session.user?.name}!</h1>\r\n      <p>Email: {session.user?.email}</p>\r\n    </div>\r\n  );\r\n}\r\n```\r\n\r\n### Middleware Protection\r\n\r\nProtect routes using the built-in middleware:\r\n\r\n```typescript\r\n// middleware.ts\r\nexport { default } from 'next-auth/middleware';\r\n\r\nexport const config = {\r\n  // Protect all routes except auth and static files\r\n  matcher: ['/((?!api|_next/static|_next/image|favicon.ico|auth|public).*)'],\r\n};\r\n```\r\n\r\n## Configuration\r\n\r\nCustomize the authentication by modifying the configuration in `src/lib/auth.ts`:\r\n\r\n```typescript\r\nimport { authConfig } from '@api-buddy/nextauth';\r\n\r\nexport const authOptions = {\r\n  ...authConfig,\r\n  providers: [\r\n    // Add your authentication providers here\r\n  ],\r\n  callbacks: {\r\n    // Customize session and JWT callbacks\r\n  },\r\n  // Other NextAuth.js configuration options\r\n};\r\n```\r\n\r\n## Available Hooks\r\n\r\n### useSession\r\n\r\nGet the current session and status:\r\n\r\n```typescript\r\nconst { data: session, status } = useSession();\r\n```\r\n\r\n### useRequiredSession\r\n\r\nA hook that redirects to the sign-in page if the user is not authenticated:\r\n\r\n```typescript\r\nconst { session, status } = useRequiredSession();\r\n```\r\n\r\n## License\r\n\r\nMIT\r\n","readmeFilename":"README.md"}