What problem does it solve?
This Skill helps you set up secure authentication in Convex by managing users, mapping identity from your auth provider, and enforcing authorization consistently across your backend.
Core Features & Use Cases
- User identity mapping: Stores provider identity (tokenIdentifier) into a Convex users table with indexes for fast lookup by token and email.
- Reusable auth helpers: Provides functions like getCurrentUser and getCurrentUserOrNull to centralize auth retrieval and reduce duplicated checks.
- Role-based authorization: Implements patterns such as requireAdmin and owner-only access for protected mutations.
- Protected vs public queries: Supports hybrid access patterns where authenticated users see more data (e.g., drafts) while anonymous users only see public records.
- First sign-in upsert: Adds a storeUser mutation to create users on first sign-in and patch/update fields on subsequent logins.
- Client authentication integration: Demonstrates WorkOS AuthKit integration for both React/Vite and Next.js, including token wiring into Convex.
Quick Start
Tell the AI: "Set up Convex authentication with a users schema, add getCurrentUser/getCurrentUserOrNull helpers, implement storeUser for first sign-in, and enforce role + ownership checks for protected mutations in my Convex app."