{
  "name": "@zewstid/nextjs",
  "versions": {
    "0.9.3": {
      "name": "@zewstid/nextjs",
      "version": "0.9.3",
      "description": "Official ZewstID SDK for Next.js - OAuth/OIDC authentication with ZewstID (12 auth methods at auth.zewstid.com)",
      "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"
        },
        "./handlers": {
          "types": "./dist/handlers.d.ts",
          "import": "./dist/handlers.mjs",
          "require": "./dist/handlers.js"
        },
        "./server": {
          "types": "./dist/server.d.ts",
          "import": "./dist/server.mjs",
          "require": "./dist/server.js"
        },
        "./middleware": {
          "types": "./dist/middleware.d.ts",
          "import": "./dist/middleware.mjs",
          "require": "./dist/middleware.js"
        },
        "./components": {
          "types": "./dist/components/index.d.ts",
          "import": "./dist/components/index.mjs",
          "require": "./dist/components/index.js"
        },
        "./package.json": "./package.json"
      },
      "files": [
        "dist",
        "README.md",
        "CHANGELOG.md",
        "LICENSE"
      ],
      "scripts": {
        "build": "tsup",
        "dev": "tsup --watch",
        "test": "jest",
        "test:watch": "jest --watch",
        "test:coverage": "jest --coverage",
        "lint": "eslint src --ext .ts,.tsx",
        "clean": "rm -rf dist"
      },
      "keywords": [
        "zewstid",
        "nextjs",
        "authentication",
        "oauth",
        "oidc",
        "password-auth",
        "password-reset",
        "forgot-password",
        "magic-links",
        "otp",
        "sms-otp",
        "webauthn",
        "passkeys",
        "biometric",
        "mfa",
        "totp",
        "2fa",
        "auth",
        "identity",
        "sso",
        "account-linking",
        "social-login",
        "identity-provider"
      ],
      "author": {
        "name": "Zewst Team"
      },
      "license": "UNLICENSED",
      "repository": {
        "type": "git",
        "url": "git+https://github.com/zewstid/zewstid-js.git",
        "directory": "packages/nextjs"
      },
      "bugs": {
        "url": "https://github.com/zewstid/zewstid-js/issues"
      },
      "homepage": "https://docs.zewstid.com/sdks/nextjs",
      "publishConfig": {
        "access": "public",
        "registry": "http://localhost:4873/"
      },
      "peerDependencies": {
        "next": "^14.0.0 || ^15.0.0",
        "react": "^18.0.0 || ^19.0.0",
        "react-dom": "^18.0.0 || ^19.0.0"
      },
      "dependencies": {
        "jose": "^5.2.0",
        "next-auth": "^4.24.0"
      },
      "devDependencies": {
        "@types/node": "^20.0.0",
        "@types/react": "^18.2.0",
        "@types/react-dom": "^18.2.0",
        "next": "^14.0.0",
        "next-auth": "^4.24.0",
        "react": "^18.0.0",
        "react-dom": "^18.0.0",
        "tsup": "^8.0.0",
        "typescript": "^5.3.0"
      },
      "_id": "@zewstid/nextjs@0.9.3",
      "readmeFilename": "README.md",
      "gitHead": "97ed0799a95137940c646dba888b244762357f7c",
      "_nodeVersion": "22.22.0",
      "_npmVersion": "10.9.4",
      "dist": {
        "integrity": "sha512-UUChLJUwpPvvvlO0E4YAtOSYEAX8Bj5LKW4K3gDoZ4F94ExAHKnwsUTLXTlsND+5wqiBB0xpLMw0enUeGfjnSQ==",
        "shasum": "00fdb1a49e98f9e79aed5818b60619a8bc029a4f",
        "tarball": "https://npm.zewstid.com/@zewstid/nextjs/-/nextjs-0.9.3.tgz"
      },
      "contributors": []
    },
    "0.9.4": {
      "name": "@zewstid/nextjs",
      "version": "0.9.4",
      "description": "Official ZewstID SDK for Next.js - OAuth/OIDC authentication with ZewstID (12 auth methods at auth.zewstid.com)",
      "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"
        },
        "./handlers": {
          "types": "./dist/handlers.d.ts",
          "import": "./dist/handlers.mjs",
          "require": "./dist/handlers.js"
        },
        "./server": {
          "types": "./dist/server.d.ts",
          "import": "./dist/server.mjs",
          "require": "./dist/server.js"
        },
        "./middleware": {
          "types": "./dist/middleware.d.ts",
          "import": "./dist/middleware.mjs",
          "require": "./dist/middleware.js"
        },
        "./components": {
          "types": "./dist/components/index.d.ts",
          "import": "./dist/components/index.mjs",
          "require": "./dist/components/index.js"
        },
        "./package.json": "./package.json"
      },
      "files": [
        "dist",
        "README.md",
        "CHANGELOG.md",
        "LICENSE"
      ],
      "scripts": {
        "build": "tsup",
        "dev": "tsup --watch",
        "test": "jest",
        "test:watch": "jest --watch",
        "test:coverage": "jest --coverage",
        "lint": "eslint src --ext .ts,.tsx",
        "clean": "rm -rf dist"
      },
      "keywords": [
        "zewstid",
        "nextjs",
        "authentication",
        "oauth",
        "oidc",
        "password-auth",
        "password-reset",
        "forgot-password",
        "magic-links",
        "otp",
        "sms-otp",
        "webauthn",
        "passkeys",
        "biometric",
        "mfa",
        "totp",
        "2fa",
        "auth",
        "identity",
        "sso",
        "account-linking",
        "social-login",
        "identity-provider"
      ],
      "author": {
        "name": "Zewst Team"
      },
      "license": "UNLICENSED",
      "repository": {
        "type": "git",
        "url": "git+https://github.com/zewstid/zewstid-js.git",
        "directory": "packages/nextjs"
      },
      "bugs": {
        "url": "https://github.com/zewstid/zewstid-js/issues"
      },
      "homepage": "https://docs.zewstid.com/sdks/nextjs",
      "publishConfig": {
        "access": "public",
        "registry": "http://localhost:4873/"
      },
      "peerDependencies": {
        "next": "^14.0.0 || ^15.0.0",
        "react": "^18.0.0 || ^19.0.0",
        "react-dom": "^18.0.0 || ^19.0.0"
      },
      "dependencies": {
        "jose": "^5.2.0",
        "next-auth": "^4.24.0"
      },
      "devDependencies": {
        "@types/node": "^20.0.0",
        "@types/react": "^18.2.0",
        "@types/react-dom": "^18.2.0",
        "next": "^14.0.0",
        "next-auth": "^4.24.0",
        "react": "^18.0.0",
        "react-dom": "^18.0.0",
        "tsup": "^8.0.0",
        "typescript": "^5.3.0"
      },
      "_id": "@zewstid/nextjs@0.9.4",
      "readmeFilename": "README.md",
      "gitHead": "f936f9df1355fa6c36b7e51210d81bb6111c90ca",
      "_nodeVersion": "22.22.0",
      "_npmVersion": "10.9.4",
      "dist": {
        "integrity": "sha512-fijEUpt+Nfyez5XUNdXuSgLeqXYF4qJrVkutbDwLlnvTWgarGcbElIFSefD+75szmTXCKdN4EvnLbFW7kkwYhA==",
        "shasum": "f496420fc2d1abc41e82c16577552ed2bd9f98eb",
        "tarball": "https://npm.zewstid.com/@zewstid/nextjs/-/nextjs-0.9.4.tgz"
      },
      "contributors": []
    },
    "0.9.5": {
      "name": "@zewstid/nextjs",
      "version": "0.9.5",
      "description": "Official ZewstID SDK for Next.js - OAuth/OIDC authentication with ZewstID (12 auth methods at auth.zewstid.com)",
      "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"
        },
        "./handlers": {
          "types": "./dist/handlers.d.ts",
          "import": "./dist/handlers.mjs",
          "require": "./dist/handlers.js"
        },
        "./server": {
          "types": "./dist/server.d.ts",
          "import": "./dist/server.mjs",
          "require": "./dist/server.js"
        },
        "./middleware": {
          "types": "./dist/middleware.d.ts",
          "import": "./dist/middleware.mjs",
          "require": "./dist/middleware.js"
        },
        "./components": {
          "types": "./dist/components/index.d.ts",
          "import": "./dist/components/index.mjs",
          "require": "./dist/components/index.js"
        },
        "./package.json": "./package.json"
      },
      "files": [
        "dist",
        "README.md",
        "CHANGELOG.md",
        "LICENSE"
      ],
      "scripts": {
        "build": "tsup",
        "dev": "tsup --watch",
        "test": "jest",
        "test:watch": "jest --watch",
        "test:coverage": "jest --coverage",
        "lint": "eslint src --ext .ts,.tsx",
        "clean": "rm -rf dist"
      },
      "keywords": [
        "zewstid",
        "nextjs",
        "authentication",
        "oauth",
        "oidc",
        "password-auth",
        "password-reset",
        "forgot-password",
        "magic-links",
        "otp",
        "sms-otp",
        "webauthn",
        "passkeys",
        "biometric",
        "mfa",
        "totp",
        "2fa",
        "auth",
        "identity",
        "sso",
        "account-linking",
        "social-login",
        "identity-provider"
      ],
      "author": {
        "name": "Zewst Team"
      },
      "license": "UNLICENSED",
      "repository": {
        "type": "git",
        "url": "git+https://github.com/zewstid/zewstid-js.git",
        "directory": "packages/nextjs"
      },
      "bugs": {
        "url": "https://github.com/zewstid/zewstid-js/issues"
      },
      "homepage": "https://docs.zewstid.com/sdks/nextjs",
      "publishConfig": {
        "access": "public",
        "registry": "http://localhost:4873/"
      },
      "peerDependencies": {
        "next": "^14.0.0 || ^15.0.0",
        "react": "^18.0.0 || ^19.0.0",
        "react-dom": "^18.0.0 || ^19.0.0"
      },
      "dependencies": {
        "jose": "^5.2.0",
        "next-auth": "^4.24.0"
      },
      "devDependencies": {
        "@types/node": "^20.0.0",
        "@types/react": "^18.2.0",
        "@types/react-dom": "^18.2.0",
        "next": "^14.0.0",
        "next-auth": "^4.24.0",
        "react": "^18.0.0",
        "react-dom": "^18.0.0",
        "tsup": "^8.0.0",
        "typescript": "^5.3.0"
      },
      "_id": "@zewstid/nextjs@0.9.5",
      "readmeFilename": "README.md",
      "gitHead": "5d8523a48edb42a9f72f52d2aa6bb29bcb2d9daf",
      "_nodeVersion": "22.22.0",
      "_npmVersion": "10.9.4",
      "dist": {
        "integrity": "sha512-G7aMVOAsBho/S8EaovXNo49bpMt2FqgTNiN62KGxcUp9cGNJRnCFs2IookC6DRMU32N1UTuaDtkFIq7lXPZyLw==",
        "shasum": "883b0bfbbe9376af71fc958a27c12ef668e53bfd",
        "tarball": "https://npm.zewstid.com/@zewstid/nextjs/-/nextjs-0.9.5.tgz"
      },
      "contributors": []
    },
    "0.9.6": {
      "name": "@zewstid/nextjs",
      "version": "0.9.6",
      "description": "Official ZewstID SDK for Next.js - OAuth/OIDC authentication with ZewstID (12 auth methods at auth.zewstid.com)",
      "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"
        },
        "./handlers": {
          "types": "./dist/handlers.d.ts",
          "import": "./dist/handlers.mjs",
          "require": "./dist/handlers.js"
        },
        "./server": {
          "types": "./dist/server.d.ts",
          "import": "./dist/server.mjs",
          "require": "./dist/server.js"
        },
        "./middleware": {
          "types": "./dist/middleware.d.ts",
          "import": "./dist/middleware.mjs",
          "require": "./dist/middleware.js"
        },
        "./components": {
          "types": "./dist/components/index.d.ts",
          "import": "./dist/components/index.mjs",
          "require": "./dist/components/index.js"
        },
        "./package.json": "./package.json"
      },
      "files": [
        "dist",
        "README.md",
        "CHANGELOG.md",
        "LICENSE"
      ],
      "scripts": {
        "build": "tsup",
        "dev": "tsup --watch",
        "test": "jest",
        "test:watch": "jest --watch",
        "test:coverage": "jest --coverage",
        "lint": "eslint src --ext .ts,.tsx",
        "clean": "rm -rf dist"
      },
      "keywords": [
        "zewstid",
        "nextjs",
        "authentication",
        "oauth",
        "oidc",
        "password-auth",
        "password-reset",
        "forgot-password",
        "magic-links",
        "otp",
        "sms-otp",
        "webauthn",
        "passkeys",
        "biometric",
        "mfa",
        "totp",
        "2fa",
        "auth",
        "identity",
        "sso",
        "account-linking",
        "social-login",
        "identity-provider"
      ],
      "author": {
        "name": "Zewst Team"
      },
      "license": "UNLICENSED",
      "repository": {
        "type": "git",
        "url": "git+https://github.com/zewstid/zewstid-js.git",
        "directory": "packages/nextjs"
      },
      "bugs": {
        "url": "https://github.com/zewstid/zewstid-js/issues"
      },
      "homepage": "https://docs.zewstid.com/sdks/nextjs",
      "publishConfig": {
        "access": "public",
        "registry": "http://localhost:4873/"
      },
      "peerDependencies": {
        "next": "^14.0.0 || ^15.0.0",
        "react": "^18.0.0 || ^19.0.0",
        "react-dom": "^18.0.0 || ^19.0.0"
      },
      "dependencies": {
        "jose": "^5.2.0",
        "next-auth": "^4.24.0"
      },
      "devDependencies": {
        "@types/node": "^20.0.0",
        "@types/react": "^18.2.0",
        "@types/react-dom": "^18.2.0",
        "next": "^14.0.0",
        "next-auth": "^4.24.0",
        "react": "^18.0.0",
        "react-dom": "^18.0.0",
        "tsup": "^8.0.0",
        "typescript": "^5.3.0"
      },
      "_id": "@zewstid/nextjs@0.9.6",
      "readmeFilename": "README.md",
      "gitHead": "138686b833859bcfc09726cb138b79e743086896",
      "_nodeVersion": "22.22.0",
      "_npmVersion": "10.9.4",
      "dist": {
        "integrity": "sha512-rvszp5j9xQMwXUtOk+9GXFY6MaEXvAn26xfJ9ub9vDxesKKnUHnbOI5cmHSQs+PMwCF+qSv1Y1XTCxZ4U+j/oQ==",
        "shasum": "b485b3492b3d05fce3eef21a682c4ab5acbcd9b0",
        "tarball": "https://npm.zewstid.com/@zewstid/nextjs/-/nextjs-0.9.6.tgz"
      },
      "contributors": []
    }
  },
  "time": {
    "modified": "2026-04-09T23:30:01.719Z",
    "created": "2026-02-28T22:39:53.811Z",
    "0.9.3": "2026-02-28T22:39:53.811Z",
    "0.9.4": "2026-03-14T16:28:28.508Z",
    "0.9.5": "2026-03-21T18:49:34.780Z",
    "0.9.6": "2026-04-09T23:30:01.719Z"
  },
  "users": {},
  "dist-tags": {
    "latest": "0.9.6"
  },
  "_rev": "12-093247e6daaef5ea",
  "_id": "@zewstid/nextjs",
  "readme": "# @zewstid/nextjs\n\nOfficial ZewstID SDK for Next.js - Simple OAuth/OIDC integration with ZewstID.\n\n[![npm version](https://img.shields.io/npm/v/@zewstid/nextjs.svg)](https://npm.zewstid.com/@zewstid/nextjs)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n> **v0.9.0**: Adds Popup Sign-In (Auth0 Lock-style) and Embedded Sign-In (Clerk-style) components. See [What's New in v0.9.0](#whats-new-in-v090) below.\n\n## ✨ Features\n\n- 🔐 **OAuth/OIDC** - Standard OpenID Connect with ZewstID\n- 🌐 **12 Auth Methods** - Password, magic links, OTP, WebAuthn, social login, MFA\n- 🪟 **Popup Sign-In** - Auth0 Lock-style popup authentication (new in v0.9.0)\n- 📋 **Embedded Sign-In** - Clerk-style inline sign-in form (new in v0.9.0)\n- 👤 **UserButton** - Clerk-style user menu with avatar dropdown (new in v0.9.0)\n- 🔄 **Cross-Portal SSO** - Automatic SSO via ZewstID session cookies\n- 🎯 **Type-Safe** - Full TypeScript support\n- 📦 **Lightweight** - Minimal footprint with tree-shaking\n- 📱 **Next.js 14/15** - Full App Router and Pages Router support\n\n## 🚀 Installation\n\n```bash\nnpm install @zewstid/nextjs next-auth\n```\n\n## 📖 Quick Start\n\n### 1. Get Your Credentials\n\nSign up at [developers.zewstid.com](https://developers.zewstid.com) and create a new application to get your:\n- Client ID\n- Client Secret\n\n### 2. Environment Variables\n\nCreate a `.env.local` file:\n\n```env\n# Required\nZEWSTID_CLIENT_ID=your_client_id\nZEWSTID_CLIENT_SECRET=your_client_secret\n# NextAuth\nNEXTAUTH_SECRET=your_random_secret_min_32_chars\nNEXTAUTH_URL=http://localhost:3000\n```\n\n### 3. Create Auth Configuration\n\n**App Router** (`app/api/auth/[...nextauth]/route.ts`):\n\n```typescript\nimport { createZewstIDAuth } from '@zewstid/nextjs';\nimport NextAuth from 'next-auth';\n\nexport const authOptions = createZewstIDAuth({\n  clientId: process.env.ZEWSTID_CLIENT_ID!,\n  clientSecret: process.env.ZEWSTID_CLIENT_SECRET!,\n});\n\nconst handler = NextAuth(authOptions);\n\nexport { handler as GET, handler as POST };\n```\n\n### 4. Wrap Your App\n\n**App Router** (`app/layout.tsx`):\n\n```tsx\nimport { ZewstIDProvider } from '@zewstid/nextjs';\n\nexport default function RootLayout({ children }: { children: React.ReactNode }) {\n  return (\n    <html>\n      <body>\n        <ZewstIDProvider>\n          {children}\n        </ZewstIDProvider>\n      </body>\n    </html>\n  );\n}\n```\n\n### 5. Add Sign In/Out Buttons\n\n```tsx\n'use client';\nimport { signIn, signOut, useSession } from 'next-auth/react';\n\nexport function AuthButtons() {\n  const { data: session } = useSession();\n\n  if (!session) {\n    return (\n      <button onClick={() => signIn('zewstid')}>\n        Sign in with ZewstID\n      </button>\n    );\n  }\n\n  return (\n    <div>\n      <p>Welcome {session.user?.name}!</p>\n      <button onClick={() => signOut()}>Sign Out</button>\n    </div>\n  );\n}\n```\n\nThat's it! Clicking \"Sign in with ZewstID\" redirects to `auth.zewstid.com` where users can authenticate using any of ZewstID's 12 authentication methods (password, magic link, OTP, WebAuthn, social login, etc.).\n\n### 6. Popup Sign-In (Optional)\n\nFor a smoother UX that keeps users on your page, use the popup sign-in component:\n\n**Step 1: Add the popup callback page** (`app/popup-callback/page.tsx`):\n\n```tsx\nimport { PopupCallback } from '@zewstid/nextjs';\n\nexport default function PopupCallbackPage() {\n  return <PopupCallback />;\n}\n```\n\n**Step 2: Use PopupSignIn component**:\n\n```tsx\n'use client';\nimport { PopupSignIn } from '@zewstid/nextjs';\nimport { useRouter } from 'next/navigation';\n\nexport function AuthButtons() {\n  const router = useRouter();\n\n  return (\n    <PopupSignIn\n      onSuccess={() => router.push('/dashboard')}\n      onError={(err) => console.error(err)}\n    >\n      Sign in with ZewstID\n    </PopupSignIn>\n  );\n}\n```\n\nThe popup opens `auth.zewstid.com` in a small window (500x700). Users authenticate there, and the popup closes automatically, updating your app's session without a full page redirect.\n\n**Props:**\n| Prop | Type | Default | Description |\n|------|------|---------|-------------|\n| `provider` | string | `\"zewstid\"` | OAuth provider ID |\n| `children` | ReactNode | `\"Sign in with ZewstID\"` | Button content |\n| `onSuccess` | `() => void` | - | Called on successful auth |\n| `onError` | `(error: string) => void` | - | Called on auth error |\n| `callbackUrl` | string | `\"/popup-callback\"` | Callback page URL |\n| `popupWidth` | number | 500 | Popup window width |\n| `popupHeight` | number | 700 | Popup window height |\n| `disabled` | boolean | false | Disable the button |\n| `className` | string | - | Custom CSS class |\n| `style` | CSSProperties | - | Custom inline styles |\n\n## 🔐 Available Authentication Methods\n\nAll authentication happens at `auth.zewstid.com`. Users see a polished login page with these options:\n\n| Method | Description |\n|--------|-------------|\n| Email/Password | Traditional login with password |\n| Magic Links | Passwordless email link |\n| Email OTP | One-time code via email |\n| SMS OTP | One-time code via SMS |\n| WebAuthn/Passkeys | Biometric or hardware key |\n| TOTP MFA | Authenticator app codes |\n| Push MFA | Approve on mobile device |\n| Google | Social login |\n| GitHub | Social login |\n| Microsoft | Social login |\n| Apple | Social login |\n| Facebook | Social login |\n\n## 🛡️ Protecting Routes\n\n### Middleware Protection\n\n```typescript\n// middleware.ts\nimport { withZewstIDAuth } from '@zewstid/nextjs/middleware';\n\nexport default withZewstIDAuth({\n  protectedPaths: ['/dashboard', '/settings', '/api/private'],\n  signInPath: '/api/auth/signin',\n});\n\nexport const config = {\n  matcher: ['/dashboard/:path*', '/settings/:path*', '/api/private/:path*'],\n};\n```\n\n### Server Component Protection\n\n```typescript\n// app/dashboard/page.tsx\nimport { getServerSession } from 'next-auth';\nimport { authOptions } from '@/app/api/auth/[...nextauth]/route';\nimport { redirect } from 'next/navigation';\n\nexport default async function DashboardPage() {\n  const session = await getServerSession(authOptions);\n\n  if (!session) {\n    redirect('/api/auth/signin');\n  }\n\n  return <div>Welcome {session.user?.name}!</div>;\n}\n```\n\n## 🔑 Role-Based Access Control (RBAC)\n\n```tsx\nimport { useRBAC, RBACProvider } from '@zewstid/nextjs';\n\n// Define your permissions\nconst rolePermissions = {\n  admin: [{ resource: '*', action: '*' }],\n  editor: [{ resource: 'posts', action: '*' }],\n  viewer: [{ resource: 'posts', action: 'read' }],\n};\n\n// Wrap your app\nfunction App({ children }) {\n  return (\n    <RBACProvider clientId=\"my-app\" rolePermissions={rolePermissions}>\n      {children}\n    </RBACProvider>\n  );\n}\n\n// Use in components\nfunction AdminPanel() {\n  const { hasRole, canAccess } = useRBAC();\n\n  if (!hasRole('admin')) {\n    return <p>Access denied</p>;\n  }\n\n  return <div>Admin Panel</div>;\n}\n```\n\n## 🚪 Logout\n\nFor proper logout that clears both NextAuth and ZewstID sessions:\n\n```typescript\n// app/api/auth/logout/route.ts\nimport { createLogoutHandler } from '@zewstid/nextjs/handlers';\nimport { authOptions } from '../[...nextauth]/route';\n\nexport const GET = createLogoutHandler(authOptions, {\n  postLogoutRedirectUri: process.env.NEXTAUTH_URL,\n});\n```\n\n```tsx\n// In your component\n<a href=\"/api/auth/logout\">Sign Out</a>\n```\n\n## 📦 API Reference\n\n### Exports from `@zewstid/nextjs`\n\n| Export | Description |\n|--------|-------------|\n| `createZewstIDAuth()` | Create NextAuth configuration |\n| `ZewstIDProvider` | Session provider wrapper |\n| `getZewstIDCallbacks()` | NextAuth callbacks for token handling |\n| `useZewstID()` | Hook for auth state (wraps useSession) |\n| `useRBAC()` | Hook for role-based access |\n| `RBACProvider` | RBAC context provider |\n| `PopupSignIn` | Popup-based sign-in button |\n| `PopupCallback` | Popup callback page component |\n| `EmbeddedSignIn` | Clerk-style inline sign-in form |\n| `UserButton` | User avatar dropdown with sign out |\n\n### Exports from `@zewstid/nextjs/handlers`\n\n| Export | Description |\n|--------|-------------|\n| `createLogoutHandler()` | Logout with ZewstID session end |\n| `createPostLogoutHandler()` | Post-logout redirect handler |\n\n### Exports from `@zewstid/nextjs/middleware`\n\n| Export | Description |\n|--------|-------------|\n| `withZewstIDAuth()` | Middleware for route protection |\n| `createClientMiddleware()` | Custom middleware creator |\n\n## 🆕 What's New in v0.9.0\n\n### Popup Sign-In (Auth0 Lock-style)\n\nOpen authentication in a popup window. No page redirect, user stays on your site.\n\n```tsx\nimport { PopupSignIn, PopupCallback } from '@zewstid/nextjs';\n\n// 1. Add a popup callback page: app/popup-callback/page.tsx\nexport default function PopupCallbackPage() {\n  return <PopupCallback />;\n}\n\n// 2. Use PopupSignIn button anywhere\nfunction LoginPage() {\n  return (\n    <PopupSignIn onSuccess={() => router.push('/dashboard')}>\n      Sign in with ZewstID\n    </PopupSignIn>\n  );\n}\n```\n\n### Embedded Sign-In (Clerk-style)\n\nFull sign-in form that renders inline on your page. Multi-step flow with password, OTP, and magic link support.\n\n```tsx\nimport { EmbeddedSignIn } from '@zewstid/nextjs';\n\nfunction LoginPage() {\n  return (\n    <EmbeddedSignIn\n      clientId={process.env.NEXT_PUBLIC_ZEWSTID_CLIENT_ID!}\n      onSuccess={({ code, email }) => {\n        // Exchange code for tokens server-side\n        fetch('/api/auth/exchange', {\n          method: 'POST',\n          body: JSON.stringify({ code }),\n        });\n      }}\n      methods={['password', 'otp', 'magic-link']}\n      showSocialLogins\n      appearance={{\n        primaryColor: '#3b82f6',\n        borderRadius: '12px',\n      }}\n    />\n  );\n}\n```\n\n### UserButton (Clerk-style)\n\nUser avatar with dropdown menu for account management and sign out.\n\n```tsx\nimport { UserButton } from '@zewstid/nextjs';\n\nfunction Header() {\n  return (\n    <nav>\n      <h1>My App</h1>\n      <UserButton afterSignOutUrl=\"/\" />\n    </nav>\n  );\n}\n```\n\n## 🔄 Migrating from v0.7.x\n\nv0.8.0 removes embedded authentication (ROPC). All authentication now uses OAuth redirect.\n\n### What Was Removed\n\n```typescript\n// ❌ These no longer work in v0.8.0\nimport { createZewstIDHandlers } from '@zewstid/nextjs/handlers'; // REMOVED\nimport { SignIn } from '@zewstid/nextjs'; // Component removed\n\n// ❌ These methods throw errors\nawait client.signInWithPassword(email, password); // Throws\nawait client.verifyMagicLink(token); // Throws\nawait client.verifyOTP(email, code); // Throws\n```\n\n### Migration Steps\n\n1. **Remove ROPC handlers**: Delete `app/api/zewstid/[...zewstid]/route.ts` if you have it.\n\n2. **Remove `<SignIn />` component**: Replace with a button that calls `signIn('zewstid')`:\n\n```tsx\n// Before (v0.7.x)\n<SignIn methods={['password', 'otp']} />\n\n// After (v0.8.0)\n<button onClick={() => signIn('zewstid')}>Sign in with ZewstID</button>\n```\n\n3. **Remove `enableSSOEstablishment`**: This option no longer exists. SSO works automatically via ZewstID session cookies.\n\n4. **Update logout**: Use `createLogoutHandler()` for proper session cleanup.\n\n### Why This Change?\n\nThe \"Google Model\" approach (redirecting to auth.zewstid.com) is:\n- **Simpler**: No ROPC handlers, no custom SSO logic\n- **More Secure**: Credentials only touch ZewstID's domain\n- **Consistent**: Same UX as Google, Microsoft, Okta\n\n## 🆘 Support\n\n- Documentation: [developers.zewstid.com](https://developers.zewstid.com)\n- Issues: [GitHub Issues](https://github.com/zewst/zewst-auth/issues)\n\n## 📄 License\n\nMIT\n",
  "_attachments": {}
}
