Back to Skills

clerk-chrome-extension-patterns

Chrome Extension auth with @clerk/chrome-extension -- popup/sidepanel setup, syncHost for OAuth/SAML via web app, createClerkClient for service workers and headless extensions, stable CRX ID. Triggers on: Chrome extension auth, Plasmo clerk, popup sign-in, syncHost, background service worker token, createClerkClient, headless extension.

44stars3forksUpdated 6/2/2026

Security Assessment

Medium Risk(50/100)

Detected risks:

Secret Exposure([SKILL.md] token =, [references/content-scripts.md] token =, [references/headless-extension.md] token =)
Sensitive File Access([SKILL.md] .env, [references/content-scripts.md] .env, [references/sync-host.md] .env)
Security Score50/100

About clerk-chrome-extension-patterns

The `clerk-chrome-extension-patterns` skill provides a structured approach to integrating authentication workflows into Chrome extensions using the @clerk/chrome-extension library. It addresses common challenges encountered when implementing secure sign-in flows within the constrained environment of browser extensions, such as handling OAuth and SAML protocols, dealing with popup and side panel limitations, and maintaining session consistency across service workers and content scripts. By offering guidelines for environment setup, stable CRX IDs, and proper handling of redirect URLs, this skill ensures that developers can implement authentication reliably without breaking user sessions or encountering origin restrictions.

The skill includes multiple authentication options, such as email/password, magic links, OTP, passkeys, and web3, and clearly delineates which methods are supported in popups, side panels, or via the `syncHost` delegation to a web app. Key features include `createClerkClient()` for service workers and headless extensions, popup-specific sign-in handling using modals, and synchronization with web app sessions to enable OAuth or SAML login flows. Critical rules emphasize best practices for handling bot protection, side panel state refreshes, and extension-specific URL constraints.

Targeted at developers building Chrome extensions with the Plasmo framework, this skill is particularly useful for those who need robust, multi-environment authentication support. It is ideal for extension authors who require seamless integration with web app sessions, reliable token handling in background service workers, and adherence to security and origin constraints enforced by Clerk. This skill enables developers to provide a smooth and consistent authentication experience for end users, regardless of the extension interface they interact with.

FAQ

Can I use OAuth or SAML directly in popups or side panels?

No. OAuth and SAML are not supported directly in popups or side panels. You must use `syncHost` to delegate authentication to your web app.

How do I handle email magic links in the popup?

Email magic links do not work in popups because the popup closes when clicking outside. Use `syncHost` via the web app to support magic link sign-ins.

Do service workers and content scripts have access to Clerk React hooks?

No. Service workers and content scripts cannot use Clerk React hooks. Use `createClerkClient()` or message passing to interact with Clerk in these contexts.

What environment variables are required for this skill?

You must set `PLASMO_PUBLIC_CLERK_PUBLISHABLE_KEY` and `CLERK_FRONTEND_API` in your environment for the extension to function correctly.

Why do I need a stable CRX ID?

Without a stable CRX ID, every rebuild of the extension breaks authentication. Configure the `key` in your manifest before deploying.

All Files

9 files
SKILL.md11.4 KB
View
references/content-scripts.md3.1 KB
View
templates/chrome-ext-basic-auth/package.json0.4 KB
View
templates/chrome-ext-basic-auth/tsconfig.json0.2 KB
View
references/sync-host.md4.1 KB
View
evals/evals.json4.8 KB
View
templates/chrome-ext-basic-auth/src/popup.tsx1.1 KB
View
references/headless-extension.md3.7 KB
View
references/create-clerk-client.md3.9 KB
View

Install clerk-chrome-extension-patterns

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

Repository

clerk/skills