riligar-dev-auth-react
npx machina-cli add skill riligar/agents-kit/riligar-dev-auth-react --openclawRiligar Auth React Skill
This skill provides a complete workflow for integrating authentication and permissions using the @riligar/auth-react SDK.
Core Integration Workflow
1. Installation
Install the SDK and its core dependencies (Mantine & Tabler Icons) using bun:
bun add @riligar/auth-react @mantine/core @mantine/hooks @mantine/notifications @tabler/icons-react
2. Environment Variables
Set up your Public Key in your environment files.
[!IMPORTANT] Always use the Public Key (
pk_...) in the frontend. Never expose your Secret Key.
# .env.development
VITE_AUTH_API_KEY=pk_test_your_public_key
# .env.production
VITE_AUTH_API_KEY=pk_live_your_public_key
3. AuthProvider Setup
Wrap your application (usually in main.jsx or App.jsx) with the AuthProvider and MantineProvider.
import { AuthProvider } from '@riligar/auth-react'
import { MantineProvider } from '@mantine/core'
ReactDOM.createRoot(document.getElementById('root')).render(
<MantineProvider theme={yourTheme}>
<AuthProvider apiKey={import.meta.env.VITE_AUTH_API_KEY}>
<App />
</AuthProvider>
</MantineProvider>
)
Ready-to-Use Templates
Use these assets to quickly scaffold a complete authentication flow:
- Routing Architecture: Comprehensive routes.jsx showing Public vs Protected patterns.
- Login & Signup: Generic signin.jsx and signup.jsx templates.
- Email Verification: verify-email.jsx handler.
- Utility Wrappers: auth-loader.jsx, require-feature.jsx, and layout.jsx.
Specialized Guides
- Hooks & UI Components: Comprehensive list of
useAuth,useSignIn, and pre-built Mantine components. See hooks-and-components.md. - Route Protection: How to use
<Protect />,<SignedIn>, and active route guards. See route-protection.md. - Core Concepts: Understanding B2C/B2B models and API key security. See concepts.md.
Common Tasks
Checking Auth State
Use useAuth() to access user data and authentication status.
const { user, isAuthenticated, loading } = useAuth()
Protecting a Dashboard
The recommended pattern is to use the Protected Group pattern with React Router as shown in routes.jsx.
// Nested routes under <Protect /> guarantee that all sub-routes are guarded.
<Route element={<Protect fallback={<AuthLoader />} />}>
<Route
path="/"
element={<Layout />}
>
<Route
index
element={<Home />}
/>
</Route>
</Route>
Source
git clone https://github.com/riligar/agents-kit/blob/prod/.agent/skills/riligar-dev-auth-react/SKILL.mdView on GitHub Overview
This skill provides a complete workflow for integrating authentication and permissions using the @riligar/auth-react SDK. It covers installation, environment setup, AuthProvider configuration, route protection, and ready-to-use UI templates and hooks for login, signup, profile, and magic links in React.
How This Skill Works
Install the SDK and Mantine dependencies, set the public key via environment variables, and wrap your app with AuthProvider (passing apiKey) alongside MantineProvider. Use hooks like useAuth and useSignIn, and route components such as Protect and SignedIn to build and guard your authentication flows.
When to Use It
- Set up authentication from scratch in a new React app
- Configure AuthProvider with your public API key
- Protect routes and guarded layouts using Protect and SignedIn
- Leverage useAuth, useSignIn, and pre-built Mantine UI components
- Handle login, signup, profile, and magic links in React
Quick Start
- Step 1: bun add @riligar/auth-react @mantine/core @mantine/hooks @mantine/notifications @tabler/icons-react
- Step 2: Set VITE_AUTH_API_KEY in .env.development and .env.production with your public key
- Step 3: Wrap your app with AuthProvider(apiKey) and MantineProvider, then start building with hooks and templates
Best Practices
- Always use the Public Key (pk_...) in the frontend; never expose your Secret Key
- Store the API key in environment variables (e.g., VITE_AUTH_API_KEY) and load it securely
- Wrap your app at the top level with AuthProvider and MantineProvider
- Start with the ready-to-use templates (routes.jsx, signin.jsx, signup.jsx) to scaffold flows
- Consult the reference guides for hooks, route protection, and core concepts
Example Use Cases
- Access current user data and authentication status via useAuth() (e.g., const { user, isAuthenticated } = useAuth())
- Protect a dashboard by wrapping routes with a nested <Protect> and using <AuthLoader/> as fallback
- Wrap your main entry (e.g., main.jsx) with <AuthProvider apiKey={VITE_AUTH_API_KEY}>
- Use the ready-made signin.jsx and signup.jsx templates to implement auth flows quickly
- Handle email verification with verify-email.jsx as part of the auth workflow