clerk-react-patterns

Implement Clerk authentication patterns for React single-page apps.

Updated May 4, 2026
One-click install
npx skills add https://github.com/Endsi3g/Uprising-AOS --skill clerk-react-patterns-endsi3g
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clerk-react-patterns
Source: https://github.com/Endsi3g/Uprising-AOS/tree/main/.agents/skills/clerk-react-patterns
Command: npx skills add https://github.com/Endsi3g/Uprising-AOS --skill clerk-react-patterns-endsi3g

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Clerk authentication often breaks in React apps when you don’t correctly handle initialization timing, protected routes, token usage, or custom sign-in flows.

Core Features & Use Cases

  • Clerk React Client-Only Auth Setup: Properly initialize ClerkProvider and use @clerk/react hooks without relying on server-side auth.
  • isLoaded-Safe Hook Usage: Use useAuth, useUser, and useClerk with correct guards to prevent undefined auth state and UI flicker.
  • Protected Routes + Redirects: Protect React Router v6/v7 routes with a ProtectedRoute pattern that redirects to sign-in when unauthenticated.
  • Custom Sign-In/Sign-Up Flows: Build email/password sign-in and sign-up flows using useSignIn and useSignUp, including status handling and activation.
  • JWT Token for API Calls: Fetch session JWTs via getToken() and attach them as Bearer tokens to backend requests.

Quick Start

Add ClerkProvider at the root in your React entry file, then create a ProtectedRoute that checks isLoaded and isSignedIn before rendering protected pages in your React Router configuration.

Frequently Asked Questions about clerk-react-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create protected routes with Clerk and React Router?

To create Clerk protected routes in React Router, implement a ProtectedRoute component that checks the isLoaded and isSignedIn state, redirecting unauthenticated users to the sign-in route before rendering protected pages.

Why does my Clerk React app flicker or show undefined auth state?

Clerk React apps flicker due to missing isLoaded guards. You must wrap useAuth, useUser, and useClerk hooks with isLoaded checks to prevent rendering components before client-only initialization completes.

How do I get a JWT token from Clerk for authenticated API calls?

To get a Clerk JWT token for API calls, use the getToken() function from Clerk React hooks to fetch the session JWT and attach it as an Authorization: Bearer header to your backend requests.

Can I build custom sign-in and sign-up flows using Clerk in React?

You can build custom Clerk sign-in and sign-up flows in React using the useSignIn and useSignUp hooks, handling email/password authentication, status updates, and user activation programmatically.

Do I need server-side rendering to use Clerk authentication in a React single-page app?

No, you do not need server-side rendering. Clerk authentication can be implemented for React single-page apps using client-only initialization by wrapping your application root with ClerkProvider.