Skip to main content
ZICQ

Skills ZICQ category:Agent Workflows clerk-react-patterns

Clerk React Patterns

'React SPA auth patterns with @clerk/react for Vite/CRA - ClerkProvider

18461 installs

Official URL:skills.sh

What this skill does

Intro in this page language first. The official description stays in its original wording; we do not rewrite SKILL.md.

What it does

'React SPA auth patterns with @clerk/react for Vite/CRA - ClerkProvider

When to use it

The official description does not include a separate “Use when”. Per the spec, agents activate this skill when the task matches keywords in that description.

How agents load it

Per Agent Skills progressive disclosure: name and description load at startup (~100 tokens); the full SKILL.md body loads when the skill activates; scripts/, references/, and assets/ load only as needed. This file's sections: React SPA Patterns; What Do You Need?; References; Setup; Mental Model; Minimal Pattern.

File analysis

File analysis: besides SKILL.md, the body references references/hooks.md, references/protected-routes.md, references/custom-flows.md, references/router-integration.md. Those resources load on demand.

React SPA PatternsWhat Do You Need?ReferencesSetupMental ModelMinimal PatternProtected Route (React Router v6/v7)Token for API CallsCommon PitfallsSee AlsoDocs

· License:MIT · allowed-tools:WebFetch

Source category:skills.sh agent-skill

SKILL.md & Agent activation

Official spec ↗
name
clerk-react-patterns
description
'React SPA auth patterns with @clerk/react for Vite/CRA - ClerkProvider
allowed-tools
WebFetchExperimental field; support depends on the client and does not grant permissions by itself.
License
MIT
  1. DiscoverThe client exposes names and descriptions to the agent.
  2. ActivateYour request or the task context selects the skill and loads its instructions.
  3. Load resourcesReferenced scripts, documentation and assets are used when needed.
Files referenced by the instructions · 4
  • references/hooks.md
  • references/protected-routes.md
  • references/custom-flows.md
  • references/router-integration.md

These paths are extracted from the text. Check the upstream package to verify the files exist.

Invocation syntax and available tools depend on your Agent client. Client integration guide ↗

Install this skill

Skills CLI ↗

Choose the target agent and installation scope, keep referenced package files, then verify the skill appears in the client's catalog.

This skill references supporting files. Retrieve the complete directory from the source; copying SKILL.md alone may leave missing dependencies.

Ask your Agent to install

Copy these instructions to a compatible agent and confirm the target directory matches your client.

Install the agent skill "clerk-react-patterns" into my project. The full SKILL.md and official description are at https://zicq.com/en/skills/skl-c2c128dfd27debb9-Clerk-React-Patterns.html
Save it as .cursor/skills/clerk-react-patterns/SKILL.md or .claude/skills/clerk-react-patterns/SKILL.md and keep the frontmatter name and description exactly as-is.
This skill also ships scripts/, references/, or assets/ — fetch the whole folder from https://github.com/clerk/skills instead of creating only a SKILL.md.

Full package on GitHub ↗

Install from the terminal · Skills CLI

Requires Node.js and npx. First inspect the repository's skill list to confirm the name.

npx skills add 'https://github.com/clerk/skills' --list

npx skills add 'https://github.com/clerk/skills' --skill 'clerk-react-patterns'

The CLI lets you choose the agent interactively. The default scope is the project; use -g for user scope. Confirm package availability with the discovery command, then use npx skills list to inspect installed skills.

Readable layout
--- name: clerk-react-patterns description: 'React SPA auth patterns with @clerk/react for Vite/CRA - ClerkProvider setup, useAuth/useUser/useClerk hooks, React Router protected routes, custom sign-in flows. Triggers on: Vite Clerk setup, React Router auth, useAuth hook, protected route, custom sign-in form React.' license: MIT allowed-tools: WebFetch metadata: author: clerk version: 1.0.0 --- # React SPA Patterns > This skill covers `@clerk/react` for Vite/CRA SPAs. For Next.js use `clerk-nextjs-patterns`. For TanStack Start use `clerk-tanstack-patterns`. ## What Do You Need? | Task | Reference | |------|-----------| | useAuth / useUser / useClerk hooks | references/hooks.md | | Protected routes with React Router | references/protected-routes.md | | Custom sign-in / sign-up forms | references/custom-flows.md | | React Router v6/v7 integration | references/router-integration.md | ## References | Reference | Description | |-----------|-------------| | `references/hooks.md` | useAuth, isLoaded guard | | `references/protected-routes.md` | ProtectedRoute pattern | | `references/custom-flows.md` | useSignIn, useSignUp flows | | `references/router-integration.md` | React Router v6/v7 setup | ## Setup ``` npm install @clerk/react ``` `.env`: ``` VITE_CLERK_PUBLISHABLE_KEY=pk_... ``` `src/main.tsx`: ```tsx import { StrictMode } from 'react' import { createRoot } from 'react-dom/client' import { ClerkProvider } from '@clerk/react' import App from './App.tsx' const PUBLISHABLE_KEY = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY createRoot(document.getElementById('root')!).render( , ) ``` ## Mental Model `@clerk/react` is client-only — there is no server-side `auth()`. All auth state comes from hooks. - `isLoaded` must be `true` before trusting `isSignedIn` — always guard on `isLoaded` - `useClerk()` gives access to `signOut`, `openSignIn`, `openUserProfile` and other methods - `getToken()` from `useAuth()` fetches the session JWT for API calls ## Minimal Pattern ```tsx import { useAuth } from '@clerk/react' export function Dashboard() { const { isLoaded, isSignedIn, userId } = useAuth() if (!isLoaded) return
Loading...
if (!isSignedIn) return
Please sign in
return
Hello {userId}
} ``` ## Protected Route (React Router v6/v7) ```tsx import { Navigate, Outlet } from 'react-router-dom' import { useAuth } from '@clerk/react' export function ProtectedRoute() { const { isLoaded, isSignedIn } = useAuth() if (!isLoaded) return
Loading...
if (!isSignedIn) return return } ``` ```tsx }> } /> } /> } /> ``` ## Token for API Calls ```tsx import { useAuth } from '@clerk/react' export function DataFetcher() { const { getToken } = useAuth() async function fetchData() { const token = await getToken() if (!token) return const res = await fetch('/api/data', { headers: { Authorization: `Bearer ${token}` }, }) return res.json() } return Load } ``` ## Common Pitfalls | Symptom | Cause | Fix | |---------|-------|-----| | `isSignedIn` is `undefined` | `isLoaded` is still `false` | Always check `isLoaded` first | | `ClerkProvider` missing | Provider not at root | Wrap `` in `main.tsx` | | Env var undefined | Wrong Vite prefix | Use `VITE_CLERK_PUBLISHABLE_KEY`, access via `import.meta.env` | | Token is `null` | User not signed in | Null-check `getToken()` result | | Sign-in component shows blank | No `publishableKey` on provider | Pass `publishableKey` explicitly | ## See Also - `clerk-setup` - Initial Clerk install - `clerk-custom-ui` - Custom flows & appearance - `clerk-orgs` - B2B organizations ## Docs [React SDK](https://clerk.com/docs/react/getting-started/quickstart)

Related skills

Agent Workflows

Skill Creator

Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that exte…

Agent Workflows

Clawdhub

Use the ClawdHub CLI to search, install, update, and publish agent skills from clawdhub.com. Use when you need to fetch new skills on the fl…

Agent Workflows

Agent Team Orchestration

Orchestrate multi-agent teams with defined roles, task lifecycles, handoff protocols, and review workflows. Use when: (1) Setting up a team …

Agent Workflows

Superpowers

Spec-first, TDD, subagent-driven software development workflow. Use when: (1) building any new feature or app — triggers brainstorm → plan →…