[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ED1TDVA5VG4MW6Y7M5BZ9B":3,"skill-same:01M7ED1TDVA5VG4MW6Y7M5BZ9B":74},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":30,"ownerHtmlUrl":31,"ownerBlogUrl":32,"ownerDescription":33,"updatedAt":34,"install":35,"resources":48},"01M7ED1TDVA5VG4MW6Y7M5BZ9B","netlify-identity",null,"当任务涉及身份验证、用户注册、登录、密码找回、OAuth 提供商、基于角色的访问控制，或保护路由和函数时使用。始终使用 `@netlify\u002Fidentity`。禁止使用 `netlify-identity-widget` 或 `gotrue-js`——这两个已废弃。","kael-odin\u002Fcodex-plugins-zh","kael-odin","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F166499071?v=4","01M7EBHJT87XN88WT3PEQ8ZGZK","Kael Odin","01M7EBHJVC91GD7PGJN3ZB14SG",37,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fkael-odin\u002Fcodex-plugins-zh\u002Fblob\u002Fmain\u002Fplugins\u002Fnetlify\u002Fskills\u002Fnetlify-identity\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fkael-odin\u002Fcodex-plugins-zh\u002Fblob\u002Fmain\u002Fplugins\u002Fnetlify\u002Fskills\u002Fnetlify-identity\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\r\nname: netlify-identity\ndescription: \"当任务涉及身份验证、用户注册、登录、密码找回、OAuth 提供商、基于角色的访问控制，或保护路由和函数时使用。始终使用 `@netlify\u002Fidentity`。禁止使用 `netlify-identity-widget` 或 `gotrue-js`——这两个已废弃。\"\r\n---\r\n\r\n# Netlify Identity\r\n\r\nNetlify Identity is a user management service for signups, logins, password recovery, user metadata, and role-based access control. It is built on [GoTrue](https:\u002F\u002Fgithub.com\u002Fnetlify\u002Fgotrue) and issues JSON Web Tokens (JWTs).\r\n\r\n**Always use `@netlify\u002Fidentity`.** Never use `netlify-identity-widget` or `gotrue-js` — they are deprecated. `@netlify\u002Fidentity` provides a unified, headless TypeScript API that works in both browser and server contexts (Netlify Functions, Edge Functions, SSR frameworks).\r\n\r\n## Setup\r\n\r\n```bash\r\nnpm install @netlify\u002Fidentity\r\n```\r\n\r\nIdentity is automatically enabled when a deploy created by a Netlify Agent Runner session includes Identity code. Otherwise, it must be manually enabled in the UI. These are the default settings:\r\n\r\n- **Registration** — Open (anyone can sign up). Change to Invite only in **Project configuration > Identity** if needed.\r\n- **Autoconfirm** — Off (new signups require email confirmation). Enable in **Project configuration > Identity** to skip confirmation during development.\r\n\r\n### Local Development\r\n\r\nIdentity does **not** currently work with `netlify dev`. You must deploy to Netlify to test Identity features. Use `npx netlify deploy` for preview deploys during development. This limitation may be resolved in a future release.\r\n\r\n## Quick Start\r\n\r\nLog in from the browser:\r\n\r\n```typescript\r\nimport { login, getUser } from '@netlify\u002Fidentity'\r\n\r\nconst user = await login('user@example.com', '\u003Cpassword>')\r\nconsole.log(`Hello, ${user.name}`)\r\n\r\n\u002F\u002F Later, check auth state\r\nconst currentUser = await getUser()\r\n```\r\n\r\nProtect a Netlify Function:\r\n\r\n```typescript\r\n\u002F\u002F netlify\u002Ffunctions\u002Fprotected.mts\r\nimport { getUser } from '@netlify\u002Fidentity'\r\nimport type { Context } from '@netlify\u002Ffunctions'\r\n\r\nexport default async (req: Request, context: Context) => {\r\n  const user = await getUser()\r\n  if (!user) return new Response('Unauthorized', { status: 401 })\r\n  return Response.json({ id: user.id, email: user.email })\r\n}\r\n```\r\n\r\n## Core API\r\n\r\nImport and use headless functions directly:\r\n\r\n```typescript\r\nimport {\r\n  getUser,\r\n  handleAuthCallback,\r\n  login,\r\n  logout,\r\n  signup,\r\n  oauthLogin,\r\n  onAuthChange,\r\n  getSettings,\r\n} from '@netlify\u002Fidentity'\r\n```\r\n\r\n### Login\r\n\r\n```typescript\r\nimport { login, AuthError } from '@netlify\u002Fidentity'\r\n\r\nasync function handleLogin(email: string, password: string) {\r\n  try {\r\n    const user = await login(email, password)\r\n    showSuccess(`Welcome back, ${user.name ?? user.email}`)\r\n  } catch (error) {\r\n    if (error instanceof AuthError) {\r\n      showError(error.status === 401 ? 'Invalid email or password.' : error.message)\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### Signup\r\n\r\nAfter signup, check `user.emailVerified` to determine if the user was auto-confirmed or needs to confirm their email.\r\n\r\n```typescript\r\nimport { signup, AuthError } from '@netlify\u002Fidentity'\r\n\r\nasync function handleSignup(email: string, password: string, name: string) {\r\n  try {\r\n    const user = await signup(email, password, { full_name: name })\r\n    if (user.emailVerified) {\r\n      \u002F\u002F Autoconfirm ON — user is logged in immediately\r\n      showSuccess('Account created. You are now logged in.')\r\n    } else {\r\n      \u002F\u002F Autoconfirm OFF — confirmation email sent\r\n      showSuccess('Check your email to confirm your account.')\r\n    }\r\n  } catch (error) {\r\n    if (error instanceof AuthError) {\r\n      showError(error.status === 403 ? 'Signups are not allowed.' : error.message)\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### Logout\r\n\r\n```typescript\r\nimport { logout } from '@netlify\u002Fidentity'\r\n\r\nawait logout()\r\n```\r\n\r\n### OAuth\r\n\r\nOAuth is a two-step flow: `oauthLogin(provider)` redirects away from the site, then `handleAuthCallback()` processes the redirect when the user returns.\r\n\r\n```typescript\r\nimport { oauthLogin } from '@netlify\u002Fidentity'\r\n\r\n\u002F\u002F Step 1: Redirect to provider (navigates away — never returns)\r\nfunction handleOAuthClick(provider: 'google' | 'github' | 'gitlab' | 'bitbucket') {\r\n  oauthLogin(provider)\r\n}\r\n```\r\n\r\nEnable providers in **Project configuration > Identity > External providers** before using OAuth.\r\n\r\n### Handling Callbacks\r\n\r\nAlways call `handleAuthCallback()` on page load in any app that uses OAuth, password recovery, invites, or email confirmation. It processes all callback types via the URL hash.\r\n\r\n```typescript\r\nimport { handleAuthCallback, AuthError } from '@netlify\u002Fidentity'\r\n\r\nasync function processCallback() {\r\n  try {\r\n    const result = await handleAuthCallback()\r\n    if (!result) return \u002F\u002F No callback hash — normal page load\r\n\r\n    switch (result.type) {\r\n      case 'oauth':\r\n        showSuccess(`Logged in as ${result.user?.email}`)\r\n        break\r\n      case 'confirmation':\r\n        showSuccess('Email confirmed. You are now logged in.')\r\n        break\r\n      case 'recovery':\r\n        \u002F\u002F User is authenticated but must set a new password\r\n        showPasswordResetForm(result.user)\r\n        break\r\n      case 'invite':\r\n        \u002F\u002F User must set a password to accept the invite\r\n        showInviteAcceptForm(result.token)\r\n        break\r\n      case 'email_change':\r\n        showSuccess('Email address updated.')\r\n        break\r\n    }\r\n  } catch (error) {\r\n    if (error instanceof AuthError) showError(error.message)\r\n  }\r\n}\r\n```\r\n\r\n### Auth State\r\n\r\n```typescript\r\nimport { getUser, onAuthChange, AUTH_EVENTS } from '@netlify\u002Fidentity'\r\n\r\n\u002F\u002F Check current user (never throws — returns null if not authenticated)\r\nconst user = await getUser()\r\n\r\n\u002F\u002F Subscribe to auth state changes (returns unsubscribe function)\r\nconst unsubscribe = onAuthChange((event, user) => {\r\n  switch (event) {\r\n    case AUTH_EVENTS.LOGIN:\r\n      console.log('Logged in:', user?.email)\r\n      break\r\n    case AUTH_EVENTS.LOGOUT:\r\n      console.log('Logged out')\r\n      break\r\n    case AUTH_EVENTS.TOKEN_REFRESH:\r\n      break\r\n    case AUTH_EVENTS.USER_UPDATED:\r\n      console.log('Profile updated:', user?.email)\r\n      break\r\n    case AUTH_EVENTS.RECOVERY:\r\n      console.log('Password recovery initiated')\r\n      break\r\n  }\r\n})\r\n```\r\n\r\n### Settings-Driven UI\r\n\r\nFetch the project's Identity settings to conditionally render signup forms and OAuth buttons.\r\n\r\n```typescript\r\nimport { getSettings } from '@netlify\u002Fidentity'\r\n\r\nconst settings = await getSettings()\r\n\u002F\u002F settings.autoconfirm — boolean\r\n\u002F\u002F settings.disableSignup — boolean\r\n\u002F\u002F settings.providers — Record\u003CAuthProvider, boolean>\r\n\r\nif (!settings.disableSignup) showSignupForm()\r\n\r\nfor (const [provider, enabled] of Object.entries(settings.providers)) {\r\n  if (enabled) showOAuthButton(provider)\r\n}\r\n```\r\n\r\n## Minimal React Example\r\n\r\n```tsx\r\nimport { useEffect, useState } from 'react'\r\nimport {\r\n  getUser,\r\n  handleAuthCallback,\r\n  login,\r\n  logout,\r\n  oauthLogin,\r\n  onAuthChange,\r\n} from '@netlify\u002Fidentity'\r\n\r\nfunction App() {\r\n  const [user, setUser] = useState(null)\r\n  const [loading, setLoading] = useState(true)\r\n\r\n  useEffect(() => {\r\n    ;(async () => {\r\n      await handleAuthCallback()\r\n      setUser(await getUser())\r\n      setLoading(false)\r\n    })()\r\n    return onAuthChange((_event, currentUser) => setUser(currentUser))\r\n  }, [])\r\n\r\n  const handleLogin = async (email, password) => {\r\n    const currentUser = await login(email, password)\r\n    setUser(currentUser)\r\n  }\r\n\r\n  const handleGoogleLogin = () => oauthLogin('google')\r\n\r\n  const handleSignOut = async () => {\r\n    await logout()\r\n    setUser(null)\r\n  }\r\n\r\n  if (loading) return \u003Cp>Loading...\u003C\u002Fp>\r\n  \u002F\u002F Render login form or user details based on `user` state\r\n}\r\n```\r\n\r\n## Error Handling\r\n\r\n`@netlify\u002Fidentity` throws two error classes:\r\n\r\n- **`AuthError`** — Thrown by auth operations. Has `message`, optional `status` (HTTP status code), and optional `cause`.\r\n- **`MissingIdentityError`** — Thrown when Identity is not configured in the current environment.\r\n\r\n`getUser()` and `isAuthenticated()` never throw — they return `null` and `false` respectively on failure.\r\n\r\n| Status | Meaning |\r\n|--------|---------|\r\n| 401 | Invalid credentials or expired token |\r\n| 403 | Action not allowed (e.g., signups disabled) |\r\n| 422 | Validation error (e.g., weak password, malformed email) |\r\n| 404 | User or resource not found |\r\n\r\n## Identity Event Functions\r\n\r\nSpecial serverless functions that trigger on Identity lifecycle events. These use the **legacy named `handler` export** (not the modern default export).\r\n\r\n**Event names:** `identity-validate`, `identity-signup`, `identity-login`\r\n\r\n```typescript\r\n\u002F\u002F netlify\u002Ffunctions\u002Fidentity-signup.mts\r\nimport type { Handler, HandlerEvent, HandlerContext } from '@netlify\u002Ffunctions'\r\n\r\nconst handler: Handler = async (event: HandlerEvent, context: HandlerContext) => {\r\n  const { user } = JSON.parse(event.body || '{}')\r\n\r\n  return {\r\n    statusCode: 200,\r\n    body: JSON.stringify({\r\n      app_metadata: {\r\n        ...user.app_metadata,\r\n        roles: ['member'],\r\n      },\r\n    }),\r\n  }\r\n}\r\n\r\nexport { handler }\r\n```\r\n\r\nThe response body replaces `app_metadata` and\u002For `user_metadata` on the user record — include all fields you want to keep.\r\n\r\n## Roles and Authorization\r\n\r\n- **`app_metadata.roles`** — Server-controlled. Only settable via the Netlify UI, admin API, or Identity event functions. Never let users set their own roles.\r\n- **`user_metadata`** — User-controlled. Users can update via `updateUser({ data: { ... } })`.\r\n\r\n### Role-Based Redirects\r\n\r\n```toml\r\n# netlify.toml\r\n[[redirects]]\r\n  from = \"\u002Fadmin\u002F*\"\r\n  to = \"\u002Fadmin\u002F:splat\"\r\n  status = 200\r\n  conditions = { Role = [\"admin\"] }\r\n\r\n[[redirects]]\r\n  from = \"\u002Fadmin\u002F*\"\r\n  to = \"\u002F\"\r\n  status = 302\r\n```\r\n\r\nRules are evaluated top-to-bottom. The `nf_jwt` cookie is read by the CDN to evaluate role conditions.\r\n\r\n## Bundled References (Load As Needed)\r\n\r\n- [Advanced patterns](references\u002Fadvanced-patterns.md) — password recovery, invite acceptance, email change, session hydration, SSR integration\r\n","# Netlify Identity\r\n\r\nNetlify Identity is a user management service for signups, logins, password recovery, user metadata, and role-based access control. It is built on [GoTrue](https:\u002F\u002Fgithub.com\u002Fnetlify\u002Fgotrue) and issues JSON Web Tokens (JWTs).\r\n\r\n**Always use `@netlify\u002Fidentity`.** Never use `netlify-identity-widget` or `gotrue-js` — they are deprecated. `@netlify\u002Fidentity` provides a unified, headless TypeScript API that works in both browser and server contexts (Netlify Functions, Edge Functions, SSR frameworks).\r\n\r\n## Setup\r\n\r\n```bash\r\nnpm install @netlify\u002Fidentity\r\n```\r\n\r\nIdentity is automatically enabled when a deploy created by a Netlify Agent Runner session includes Identity code. Otherwise, it must be manually enabled in the UI. These are the default settings:\r\n\r\n- **Registration** — Open (anyone can sign up). Change to Invite only in **Project configuration > Identity** if needed.\r\n- **Autoconfirm** — Off (new signups require email confirmation). Enable in **Project configuration > Identity** to skip confirmation during development.\r\n\r\n### Local Development\r\n\r\nIdentity does **not** currently work with `netlify dev`. You must deploy to Netlify to test Identity features. Use `npx netlify deploy` for preview deploys during development. This limitation may be resolved in a future release.\r\n\r\n## Quick Start\r\n\r\nLog in from the browser:\r\n\r\n```typescript\r\nimport { login, getUser } from '@netlify\u002Fidentity'\r\n\r\nconst user = await login('user@example.com', '\u003Cpassword>')\r\nconsole.log(`Hello, ${user.name}`)\r\n\r\n\u002F\u002F Later, check auth state\r\nconst currentUser = await getUser()\r\n```\r\n\r\nProtect a Netlify Function:\r\n\r\n```typescript\r\n\u002F\u002F netlify\u002Ffunctions\u002Fprotected.mts\r\nimport { getUser } from '@netlify\u002Fidentity'\r\nimport type { Context } from '@netlify\u002Ffunctions'\r\n\r\nexport default async (req: Request, context: Context) => {\r\n  const user = await getUser()\r\n  if (!user) return new Response('Unauthorized', { status: 401 })\r\n  return Response.json({ id: user.id, email: user.email })\r\n}\r\n```\r\n\r\n## Core API\r\n\r\nImport and use headless functions directly:\r\n\r\n```typescript\r\nimport {\r\n  getUser,\r\n  handleAuthCallback,\r\n  login,\r\n  logout,\r\n  signup,\r\n  oauthLogin,\r\n  onAuthChange,\r\n  getSettings,\r\n} from '@netlify\u002Fidentity'\r\n```\r\n\r\n### Login\r\n\r\n```typescript\r\nimport { login, AuthError } from '@netlify\u002Fidentity'\r\n\r\nasync function handleLogin(email: string, password: string) {\r\n  try {\r\n    const user = await login(email, password)\r\n    showSuccess(`Welcome back, ${user.name ?? user.email}`)\r\n  } catch (error) {\r\n    if (error instanceof AuthError) {\r\n      showError(error.status === 401 ? 'Invalid email or password.' : error.message)\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### Signup\r\n\r\nAfter signup, check `user.emailVerified` to determine if the user was auto-confirmed or needs to confirm their email.\r\n\r\n```typescript\r\nimport { signup, AuthError } from '@netlify\u002Fidentity'\r\n\r\nasync function handleSignup(email: string, password: string, name: string) {\r\n  try {\r\n    const user = await signup(email, password, { full_name: name })\r\n    if (user.emailVerified) {\r\n      \u002F\u002F Autoconfirm ON — user is logged in immediately\r\n      showSuccess('Account created. You are now logged in.')\r\n    } else {\r\n      \u002F\u002F Autoconfirm OFF — confirmation email sent\r\n      showSuccess('Check your email to confirm your account.')\r\n    }\r\n  } catch (error) {\r\n    if (error instanceof AuthError) {\r\n      showError(error.status === 403 ? 'Signups are not allowed.' : error.message)\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### Logout\r\n\r\n```typescript\r\nimport { logout } from '@netlify\u002Fidentity'\r\n\r\nawait logout()\r\n```\r\n\r\n### OAuth\r\n\r\nOAuth is a two-step flow: `oauthLogin(provider)` redirects away from the site, then `handleAuthCallback()` processes the redirect when the user returns.\r\n\r\n```typescript\r\nimport { oauthLogin } from '@netlify\u002Fidentity'\r\n\r\n\u002F\u002F Step 1: Redirect to provider (navigates away — never returns)\r\nfunction handleOAuthClick(provider: 'google' | 'github' | 'gitlab' | 'bitbucket') {\r\n  oauthLogin(provider)\r\n}\r\n```\r\n\r\nEnable providers in **Project configuration > Identity > External providers** before using OAuth.\r\n\r\n### Handling Callbacks\r\n\r\nAlways call `handleAuthCallback()` on page load in any app that uses OAuth, password recovery, invites, or email confirmation. It processes all callback types via the URL hash.\r\n\r\n```typescript\r\nimport { handleAuthCallback, AuthError } from '@netlify\u002Fidentity'\r\n\r\nasync function processCallback() {\r\n  try {\r\n    const result = await handleAuthCallback()\r\n    if (!result) return \u002F\u002F No callback hash — normal page load\r\n\r\n    switch (result.type) {\r\n      case 'oauth':\r\n        showSuccess(`Logged in as ${result.user?.email}`)\r\n        break\r\n      case 'confirmation':\r\n        showSuccess('Email confirmed. You are now logged in.')\r\n        break\r\n      case 'recovery':\r\n        \u002F\u002F User is authenticated but must set a new password\r\n        showPasswordResetForm(result.user)\r\n        break\r\n      case 'invite':\r\n        \u002F\u002F User must set a password to accept the invite\r\n        showInviteAcceptForm(result.token)\r\n        break\r\n      case 'email_change':\r\n        showSuccess('Email address updated.')\r\n        break\r\n    }\r\n  } catch (error) {\r\n    if (error instanceof AuthError) showError(error.message)\r\n  }\r\n}\r\n```\r\n\r\n### Auth State\r\n\r\n```typescript\r\nimport { getUser, onAuthChange, AUTH_EVENTS } from '@netlify\u002Fidentity'\r\n\r\n\u002F\u002F Check current user (never throws — returns null if not authenticated)\r\nconst user = await getUser()\r\n\r\n\u002F\u002F Subscribe to auth state changes (returns unsubscribe function)\r\nconst unsubscribe = onAuthChange((event, user) => {\r\n  switch (event) {\r\n    case AUTH_EVENTS.LOGIN:\r\n      console.log('Logged in:', user?.email)\r\n      break\r\n    case AUTH_EVENTS.LOGOUT:\r\n      console.log('Logged out')\r\n      break\r\n    case AUTH_EVENTS.TOKEN_REFRESH:\r\n      break\r\n    case AUTH_EVENTS.USER_UPDATED:\r\n      console.log('Profile updated:', user?.email)\r\n      break\r\n    case AUTH_EVENTS.RECOVERY:\r\n      console.log('Password recovery initiated')\r\n      break\r\n  }\r\n})\r\n```\r\n\r\n### Settings-Driven UI\r\n\r\nFetch the project's Identity settings to conditionally render signup forms and OAuth buttons.\r\n\r\n```typescript\r\nimport { getSettings } from '@netlify\u002Fidentity'\r\n\r\nconst settings = await getSettings()\r\n\u002F\u002F settings.autoconfirm — boolean\r\n\u002F\u002F settings.disableSignup — boolean\r\n\u002F\u002F settings.providers — Record\u003CAuthProvider, boolean>\r\n\r\nif (!settings.disableSignup) showSignupForm()\r\n\r\nfor (const [provider, enabled] of Object.entries(settings.providers)) {\r\n  if (enabled) showOAuthButton(provider)\r\n}\r\n```\r\n\r\n## Minimal React Example\r\n\r\n```tsx\r\nimport { useEffect, useState } from 'react'\r\nimport {\r\n  getUser,\r\n  handleAuthCallback,\r\n  login,\r\n  logout,\r\n  oauthLogin,\r\n  onAuthChange,\r\n} from '@netlify\u002Fidentity'\r\n\r\nfunction App() {\r\n  const [user, setUser] = useState(null)\r\n  const [loading, setLoading] = useState(true)\r\n\r\n  useEffect(() => {\r\n    ;(async () => {\r\n      await handleAuthCallback()\r\n      setUser(await getUser())\r\n      setLoading(false)\r\n    })()\r\n    return onAuthChange((_event, currentUser) => setUser(currentUser))\r\n  }, [])\r\n\r\n  const handleLogin = async (email, password) => {\r\n    const currentUser = await login(email, password)\r\n    setUser(currentUser)\r\n  }\r\n\r\n  const handleGoogleLogin = () => oauthLogin('google')\r\n\r\n  const handleSignOut = async () => {\r\n    await logout()\r\n    setUser(null)\r\n  }\r\n\r\n  if (loading) return \u003Cp>Loading...\u003C\u002Fp>\r\n  \u002F\u002F Render login form or user details based on `user` state\r\n}\r\n```\r\n\r\n## Error Handling\r\n\r\n`@netlify\u002Fidentity` throws two error classes:\r\n\r\n- **`AuthError`** — Thrown by auth operations. Has `message`, optional `status` (HTTP status code), and optional `cause`.\r\n- **`MissingIdentityError`** — Thrown when Identity is not configured in the current environment.\r\n\r\n`getUser()` and `isAuthenticated()` never throw — they return `null` and `false` respectively on failure.\r\n\r\n| Status | Meaning |\r\n|--------|---------|\r\n| 401 | Invalid credentials or expired token |\r\n| 403 | Action not allowed (e.g., signups disabled) |\r\n| 422 | Validation error (e.g., weak password, malformed email) |\r\n| 404 | User or resource not found |\r\n\r\n## Identity Event Functions\r\n\r\nSpecial serverless functions that trigger on Identity lifecycle events. These use the **legacy named `handler` export** (not the modern default export).\r\n\r\n**Event names:** `identity-validate`, `identity-signup`, `identity-login`\r\n\r\n```typescript\r\n\u002F\u002F netlify\u002Ffunctions\u002Fidentity-signup.mts\r\nimport type { Handler, HandlerEvent, HandlerContext } from '@netlify\u002Ffunctions'\r\n\r\nconst handler: Handler = async (event: HandlerEvent, context: HandlerContext) => {\r\n  const { user } = JSON.parse(event.body || '{}')\r\n\r\n  return {\r\n    statusCode: 200,\r\n    body: JSON.stringify({\r\n      app_metadata: {\r\n        ...user.app_metadata,\r\n        roles: ['member'],\r\n      },\r\n    }),\r\n  }\r\n}\r\n\r\nexport { handler }\r\n```\r\n\r\nThe response body replaces `app_metadata` and\u002For `user_metadata` on the user record — include all fields you want to keep.\r\n\r\n## Roles and Authorization\r\n\r\n- **`app_metadata.roles`** — Server-controlled. Only settable via the Netlify UI, admin API, or Identity event functions. Never let users set their own roles.\r\n- **`user_metadata`** — User-controlled. Users can update via `updateUser({ data: { ... } })`.\r\n\r\n### Role-Based Redirects\r\n\r\n```toml\r\n# netlify.toml\r\n[[redirects]]\r\n  from = \"\u002Fadmin\u002F*\"\r\n  to = \"\u002Fadmin\u002F:splat\"\r\n  status = 200\r\n  conditions = { Role = [\"admin\"] }\r\n\r\n[[redirects]]\r\n  from = \"\u002Fadmin\u002F*\"\r\n  to = \"\u002F\"\r\n  status = 302\r\n```\r\n\r\nRules are evaluated top-to-bottom. The `nf_jwt` cookie is read by the CDN to evaluate role conditions.\r\n\r\n## Bundled References (Load As Needed)\r\n\r\n- [Advanced patterns](references\u002Fadvanced-patterns.md) — password recovery, invite acceptance, email change, session hydration, SSR integration\r\n",{"name":5,"description":7},"main","e3091d1b371a9dcd9455d333175f948b286fdfcf","plugins\u002Fnetlify\u002Fskills\u002Fnetlify-identity",1,"https:\u002F\u002Fgithub.com\u002Fkael-odin\u002Fcodex-plugins-zh","https:\u002F\u002Fkael-odin.github.io\u002Fcodex-plugins-zh\u002F","https:\u002F\u002Fgithub.com\u002Fkael-odin","https:\u002F\u002Fkael-odin.github.io\u002Fodin-valhalla\u002F","Full-stack development • Open-source • System engineering\r\nTurning ideas into repositories.","2026-11-08 17:05:36",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add kael-odin\u002Fcodex-plugins-zh --skill netlify-identity",{"tool":41,"command":42},"bunx","bunx skills add kael-odin\u002Fcodex-plugins-zh --skill netlify-identity",{"tool":44,"command":45},"pnpm","pnpm dlx skills add kael-odin\u002Fcodex-plugins-zh --skill netlify-identity","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fkael-odin\u002Fcodex-plugins-zh\u002Fblob\u002Fmain\u002Fplugins\u002Fnetlify\u002Fskills\u002Fnetlify-identity\u002FSKILL.md",true,[49,55,61,65,70],{"path":50,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":53,"sourceHtmlUrl":54},"agents\u002Fopenai.yaml","REFERENCE","参考文档",341,"https:\u002F\u002Fgithub.com\u002Fkael-odin\u002Fcodex-plugins-zh\u002Fblob\u002Fmain\u002Fplugins\u002Fnetlify\u002Fskills\u002Fnetlify-identity\u002Fagents\u002Fopenai.yaml",{"path":56,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":59,"sourceHtmlUrl":60},"assets\u002Fnetlify-small.svg","ASSET","资产文件",1302,"https:\u002F\u002Fgithub.com\u002Fkael-odin\u002Fcodex-plugins-zh\u002Fblob\u002Fmain\u002Fplugins\u002Fnetlify\u002Fskills\u002Fnetlify-identity\u002Fassets\u002Fnetlify-small.svg",{"path":62,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":63,"sourceHtmlUrl":64},"assets\u002Fnetlify.png",2686,"https:\u002F\u002Fgithub.com\u002Fkael-odin\u002Fcodex-plugins-zh\u002Fblob\u002Fmain\u002Fplugins\u002Fnetlify\u002Fskills\u002Fnetlify-identity\u002Fassets\u002Fnetlify.png",{"path":66,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":69,"sourceHtmlUrl":16},"LICENSE.txt","LICENSE","许可证",10977,{"path":71,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":72,"sourceHtmlUrl":73},"references\u002Fadvanced-patterns.md",4201,"https:\u002F\u002Fgithub.com\u002Fkael-odin\u002Fcodex-plugins-zh\u002Fblob\u002Fmain\u002Fplugins\u002Fnetlify\u002Fskills\u002Fnetlify-identity\u002Freferences\u002Fadvanced-patterns.md",[75,83,91,99,106,113],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":79,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":20},"01M7EDVCKB89EF755PQMKV1BZA","android-emulator-qa","Use when validating Android feature flows in an emulator with adb-driven launch, input, UI-tree inspection, screenshots, and logcat capture.","https:\u002F\u002Fgithub.com\u002Fkael-odin\u002Fcodex-plugins-zh\u002Fblob\u002Fmain\u002Fplugins\u002Ftest-android-apps\u002Fskills\u002Fandroid-emulator-qa\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fkael-odin\u002Fcodex-plugins-zh\u002Fblob\u002Fmain\u002Fplugins\u002Ftest-android-apps\u002Fskills\u002Fandroid-emulator-qa\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":20},"01M7EDPX7WHN6HQZ0QKWB0BGVZ","supabase-postgres-best-practices","Postgres performance optimization and best practices from Supabase. Use this skill when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations.","MIT","https:\u002F\u002Fgithub.com\u002Fkael-odin\u002Fcodex-plugins-zh\u002Fblob\u002Fmain\u002Fplugins\u002Fsupabase\u002Fskills\u002Fsupabase-postgres-best-practices\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":95,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":20},"01M7EDHHD98T8ZH09F40Q973G3","sentry","Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.","https:\u002F\u002Fgithub.com\u002Fkael-odin\u002Fcodex-plugins-zh\u002Fblob\u002Fmain\u002Fplugins\u002Fsentry\u002Fskills\u002Fsentry\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fkael-odin\u002Fcodex-plugins-zh\u002Fblob\u002Fmain\u002Fplugins\u002Fsentry\u002Fskills\u002Fsentry\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":20},"01M7EDH3SGVMS1AFS6Q40B5J48","render-workflows","搭建、开发、测试和部署 Render Workflows。涵盖首次脚手架搭建（通过 CLI 或手动方式）、SDK 安装（Python 或 TypeScript）、任务模式（重试、子任务、扇出）、本地开发、控制台部署和故障排查。适用于用户首次搭建 Render Workflows、构建工作流服务、添加或修改工作流任务、本地测试工作流或部署到 Render 的场景。","https:\u002F\u002Fgithub.com\u002Fkael-odin\u002Fcodex-plugins-zh\u002Fblob\u002Fmain\u002Fplugins\u002Frender\u002Fskills\u002Frender-workflows\u002FSKILL.md",[],[],{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":20},"01M7EDH0CYEKQ4VVARHZAQ43S8","render-web-services","配置 Render web service——端口绑定、TLS、健康检查、自定义域名、自动部署、PR 预览、持久化磁盘及部署生命周期。当用户需要搭建 web service、修复健康检查失败、添加自定义域名、配置零停机部署，或排查端口绑定问题时使用。","https:\u002F\u002Fgithub.com\u002Fkael-odin\u002Fcodex-plugins-zh\u002Fblob\u002Fmain\u002Fplugins\u002Frender\u002Fskills\u002Frender-web-services\u002FSKILL.md",[],[],{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":20},"01M7EDGVDYFBG1CKSNMQ2DD336","render-static-sites","在 Render 全球 CDN 上部署并配置静态站点——构建命令、发布路径、SPA 路由、重定向、自定义 header 及 PR 预览。当用户需要部署静态站点、搭建 React\u002FVue\u002FHugo\u002FGatsby 前端、配置 SPA 回退路由、添加重定向规则、自定义响应 header，或在静态站点与 web service 之间为前端做选择时使用。触发词:static site、CDN、SPA、single-page app、React deploy、Vue deploy、Hugo、Gatsby、Docusaurus、Jekyll、staticPublishPath。","https:\u002F\u002Fgithub.com\u002Fkael-odin\u002Fcodex-plugins-zh\u002Fblob\u002Fmain\u002Fplugins\u002Frender\u002Fskills\u002Frender-static-sites\u002FSKILL.md",[],[]]