{"id":18096,"library":"ag-common-next-auth","title":"ag-common-next-auth","description":"A set of reusable utilities for NextAuth.js, including OAuth callback handlers, session management, and Cognito integration. Current stable version 0.0.153. Released frequently (multiple versions per week) but still in early development. Key differentiators: provides pre-built NextAuth adapters and helpers for common providers, with TypeScript types included. Minimal documentation and limited community adoption; use with caution in production.","status":"active","version":"0.0.153","language":"javascript","source_language":"en","source_url":"https://github.com/andreigec/ag-common-next-auth","tags":["javascript","typescript"],"install":[{"cmd":"npm install ag-common-next-auth","lang":"bash","label":"npm"},{"cmd":"yarn add ag-common-next-auth","lang":"bash","label":"yarn"},{"cmd":"pnpm add ag-common-next-auth","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for NextAuth.js types and session handling","package":"next-auth","optional":false}],"imports":[{"note":"Named export only; no default export.","wrong":"import OAuthCallback from 'ag-common-next-auth'","symbol":"OAuthCallback","correct":"import { OAuthCallback } from 'ag-common-next-auth'"},{"note":"ESM-only; CommonJS require works but is discouraged.","wrong":"const checkEnvironment = require('ag-common-next-auth').checkEnvironment","symbol":"checkEnvironment","correct":"import { checkEnvironment } from 'ag-common-next-auth'"},{"note":"Subpath export; not available from main entry.","wrong":"import { CognitoProvider } from 'ag-common-next-auth'","symbol":"CognitoProvider","correct":"import { CognitoProvider } from 'ag-common-next-auth/providers/cognito'"}],"quickstart":{"code":"import { OAuthCallback } from 'ag-common-next-auth';\n\nexport async function handler(req, res) {\n  const result = await OAuthCallback(req, res, {\n    clientId: process.env.COGNITO_CLIENT_ID ?? '',\n    clientSecret: process.env.COGNITO_CLIENT_SECRET ?? '',\n    redirectUri: 'https://example.com/api/auth/callback',\n  });\n  console.log('OAuth result:', result);\n}","lang":"typescript","description":"Shows how to use OAuthCallback handler with Cognito provider, including environment variable fallbacks."},"warnings":[{"fix":"Ensure both variables are defined in your deployment environment (Vercel, etc.).","message":"Environment variables COGNITO_CLIENT_SECRET and NEXTAUTH_SECRET must be set, otherwise OAuthCallback will throw an error.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Update imports: replace `OAuthHandler` with `OAuthCallback`.","message":"Version 0.0.150 renamed `OAuthHandler` to `OAuthCallback`. Old imports break.","severity":"breaking","affected_versions":"<0.0.150"},{"fix":"Replace `validateSession()` with `checkEnvironment()`.","message":"Function `validateSession` was deprecated in v0.0.130; use `checkEnvironment` instead.","severity":"deprecated","affected_versions":">=0.0.130"},{"fix":"Import from 'ag-common-next-auth/providers/cognito'.","message":"CognitoProvider is not exported from the main package entry; it requires a subpath import.","severity":"gotcha","affected_versions":">=0.0.140"},{"fix":"Use ES import syntax; if using Node.js <14, upgrade or use dynamic import().","message":"In v0.0.120, the package switched from CommonJS to ESM-only. `require()` still works but may cause issues with dynamic imports.","severity":"breaking","affected_versions":">=0.0.120"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use `import { OAuthCallback } from 'ag-common-next-auth'`","cause":"Importing default export instead of named export.","error":"Error: OAuthCallback is not defined"},{"fix":"Add them to your .env file or hosting environment.","cause":"Environment variables COGNITO_CLIENT_ID or COGNITO_CLIENT_SECRET missing.","error":"TypeError: Cannot read properties of undefined (reading 'clientId')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}