clerk-react-patterns

Implement Clerk authentication in React SPAs with protected routes and user profiles.

Updated Apr 28, 2026
One-click install
npx skills add https://github.com/weng-lab/APIConsole --skill clerk-react-patterns-weng-lab
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clerk-react-patterns
Source: https://github.com/weng-lab/APIConsole/tree/main/.agents/skills/clerk-react-patterns
Command: npx skills add https://github.com/weng-lab/APIConsole --skill clerk-react-patterns-weng-lab

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill simplifies building secure authentication flows for React single-page applications by providing a ready-to-use Clerk integration with common patterns such as sign-in/out, protected routes, and user profiles.

Core Features & Use Cases

  • UseAuth, useUser, and useClerk hooks to manage authentication state and user data.
  • Protected routes with React Router integration to guard sensitive pages.
  • Custom sign-in / sign-up flows that plug into Clerk's system and support post-auth navigation.

Quick Start

Install @clerk/react in your React app, wrap your root in ClerkProvider, and add sign-in/out UI along with protected routes to enable authentication.

Frequently Asked Questions about clerk-react-patterns

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

FAQPage Schema
How do I set up protected routes in a React SPA using Clerk?

Protected routes in a React SPA using Clerk are set up by integrating React Router with Clerk's hooks to guard sensitive pages. Wrap your root component in ClerkProvider and apply an isSignedIn guard to redirect unauthenticated users.

What is the best way to manage user authentication state in React with Clerk?

Managing user authentication state in React with Clerk is handled through the useAuth, useUser, and useClerk hooks. These hooks provide direct access to authentication state and user data to render sign-in/out controls and manage sessions.

Can I build custom sign-in and sign-up flows in a React SPA with Clerk?

Yes, you can build custom sign-in and sign-up flows in a React SPA with Clerk. The integration plugs into Clerk's system and supports post-auth navigation, allowing you to build custom UI components for user authentication.

Does Clerk authentication work with Vite or Create React App?

Yes, Clerk authentication works with both Vite and Create React App based React SPAs. You need to install the @clerk/react package, wrap your root in ClerkProvider, and add the required auth UI and protected routes.

How do I handle user sessions in a React single-page application?

Handling user sessions in a React single-page application is done using Clerk's useClerk and useAuth hooks. These hooks manage authentication state and allow you to render sign-in/out controls to start or end user sessions.