Back to Skills

netlify-identity

Add authentication and user management to a Netlify site with @netlify/identity — signup/login/logout, OAuth social login (Google/GitHub/GitLab/Bitbucket), server-side user verification in Functions, role-based access control (RBAC), admin user management, and Identity event hooks. Use when adding a login/signup flow, "add social login", gating content by user role, protecting a function or page behind auth, assigning roles at signup, customizing auth emails, or handling OAuth/confirmation/recov

34stars7forksUpdated 8/14/2026

Security Assessment

Safe(94/100)
Security Score94/100

About netlify-identity

This skill guides an agent through adding authentication and user management to a Netlify site using the `@netlify/identity` package. It covers signup/login/logout, OAuth social login (Google, GitHub, GitLab, Bitbucket), server-side user verification in Functions, role-based access control, admin user management, and Identity event hooks. It solves the recurring problem of wiring up auth on Netlify correctly by steering away from the legacy widget and gotrue-js and toward the modern package's simpler API and built-in server-side support.

Much of the value is in its security-conscious "footguns" guidance. It warns that Identity does not work under `netlify dev` (test on a deploy preview), that building a from-scratch third-party OAuth flow beside Identity is the most common source of rework (use `oauthLogin()` and `handleAuthCallback()` instead), and that Identity settings are dashboard-only with no public API to curl or token files to read. It emphasizes CSRF protection via `verifyRequestOrigin()` for server-side auth mutations, mandatory callback handling, and rendering providers from `getSettings()` rather than hard-coding them. Reference files go deep on authorization and sessions: admin operations run only in the Functions runtime with a runtime-provided token (never hardcoded or shipped client-side), redirect gating is only a coarse CDN-level perimeter that SPA navigation bypasses, sensitive checks must be enforced server-side against server-controlled app_metadata.roles, and role changes do not affect live sessions until the JWT refreshes. Advanced patterns cover password recovery, invite acceptance, email change, session hydration, and SSR integration.

It targets web developers building login/signup flows, social login, role-gated content, or protected functions on Netlify. It explicitly defers whole-site locking to a separate netlify-access-control skill.

FAQ

Which package should I use?

The modern `@netlify/identity` package. The skill advises against the legacy `netlify-identity-widget` and `gotrue-js` for new work because the new package has the same capabilities with a simpler API and built-in server-side support.

Can I test auth flows locally with netlify dev?

No. Identity does not work under `netlify dev`; the `/.netlify/identity/*` endpoints are unreachable there, so auth flows must be tested on a deploy, and Deploy Previews work for this.

How is role-based access actually enforced securely?

Redirect gating is only a coarse CDN document-request perimeter that SPA navigation bypasses. Anything sensitive must be enforced server-side on every request in a Function that resolves the user with getUser() and checks the server-controlled app_metadata.roles.

Why doesn't a role change take effect immediately?

Roles are baked into the nf_jwt when issued and stay valid until it expires (about an hour). A role change applies only after the token refreshes or the user logs out and back in.

How are admin operations handled safely?

Admin operations run only in the Netlify Functions runtime, which provides the privileged token automatically. The skill stresses never hardcoding an admin token, shipping it in the client bundle, or exposing admin operations to the browser.

All Files

3 files
references/authorization-and-sessions.md3.3 KB
View
references/advanced-patterns.md4.3 KB
View
SKILL.md15.2 KB
View

Install netlify-identity

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill