{"library":"mytpen-auth","title":"MYTPEN Auth Integration Package","description":"The `mytpen-auth` package, currently at version 1.1.15, is designed to provide a robust and simplified authentication integration solution for applications leveraging MYTPEN's OIDC (OpenID Connect) services, with a strong focus on Next.js `app` directory projects. It abstracts the complexities of OIDC flows by offering pre-built API route handlers and React context providers, streamlining the setup process significantly. A key feature is its requirement for Redis (via `@upstash/redis`) for secondary storage, enabling efficient session management and state persistence across serverless functions. The package ships with comprehensive TypeScript types, ensuring a type-safe development experience. It operates on Node.js environments version 18.0.0 or higher and has peer dependencies on React and React DOM, both version 19.0.0 or higher. The package undergoes iterative development, with minor version updates reflecting ongoing enhancements and specific platform integrations.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install mytpen-auth"],"cli":null},"imports":["import { auth } from 'mytpen-auth';","import { toNextJsHandler } from 'mytpen-auth';","import { MytpenAuthProvider } from 'mytpen-auth/provider';","import { getCurrentPathname } from 'mytpen-auth/nextjs';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"    // In your .env file (or configured in deployment environment):\n    // MYTPEN_AUTH_SECRET=\"your-strong-random-secret-key\"\n    // MYTPEN_PROVIDER_ID=\"your-app-id-from-dashboard\"\n    // MYTPEN_CLIENT_ID=\"your-client-id-from-dashboard\"\n    // MYTPEN_CLIENT_SECRET=\"your-client-secret-from-dashboard\"\n    // MYTPEN_AUTH_SERVER=\"https://dashboard.mytpen.app\" (or your IdP origin)\n    // MYTPEN_AUTH_BASEURL=\"http://localhost:3000\" (or your app's base URL for callbacks)\n    // UPSTASH_REDIS_REST_URL=\"https://your-instance.upstash.io\"\n    // UPSTASH_REDIS_REST_TOKEN=\"your-upstash-rest-token\"\n\n    // app/api/auth/[...all]/route.ts\n    import { auth, toNextJsHandler } from \"mytpen-auth\";\n\n    // Export GET and POST handlers for the Next.js API route\n    export const { GET, POST } = toNextJsHandler(auth);\n\n    // app/layout.tsx\n    import { MytpenAuthProvider } from \"mytpen-auth/provider\";\n    import { LogoSvg } from \"mytpen-auth/components\"; // Example component (optional)\n    import { getCurrentPathname } from \"mytpen-auth/nextjs\"; // Example utility (optional)\n    import \"./globals.css\"; // Assuming you have global styles\n\n    export default function RootLayout({\n      children,\n    }: {\n      children: React.ReactNode;\n    }) {\n      const pathname = getCurrentPathname(); // Example usage of a utility\n\n      return (\n        <html lang=\"en\">\n          <body>\n            <MytpenAuthProvider>\n              <header style={{ display: 'flex', justifyContent: 'space-between', padding: '1rem', borderBottom: '1px solid #eee' }}>\n                <LogoSvg width={100} height={30} />\n                <nav>\n                  <a href=\"/dashboard\" style={{ margin: '0 0.5rem' }}>Dashboard</a>\n                  <a href=\"/profile\" style={{ margin: '0 0.5rem' }}>Profile</a>\n                  <a href=\"/api/auth/signout\" style={{ margin: '0 0.5rem' }}>Sign Out</a>\n                </nav>\n              </header>\n              <main style={{ minHeight: '80vh', padding: '2rem' }}>\n                {children}\n              </main>\n              <footer style={{ marginTop: '2rem', textAlign: 'center', color: '#888' }}>\n                <p>Application Footer - Current Path: {pathname}</p>\n              </footer>\n            </MytpenAuthProvider>\n          </body>\n        </html>\n      );\n    }\n    ","lang":"typescript","description":"This quickstart demonstrates the essential configuration for `mytpen-auth` within a Next.js `app` directory project. It includes setting up the API route handler, integrating `MytpenAuthProvider` into the root layout, and highlights the critical environment variables required for successful authentication and Redis integration.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}