Overview
Theusers table stores user authentication data, subscription status, and project limits. It integrates with Stack Auth for authentication and Autumn for billing.
Schema
Stack Auth user ID (primary authentication identifier)
Legacy Clerk user ID - maintained during migration period from Clerk to Stack Auth
User’s email address
Autumn billing customer ID for subscription management
Current subscription statusPossible values:
free- Free tier (10 projects)trialing- In trial period (7 days)active- Active paid subscriptionpaused- Subscription pausedcanceled- Subscription canceledpast_due- Payment failed
Subscription tier levelPossible values:
free- Free tier (10 projects)pro_monthly- Pro monthly ($29/mo, unlimited projects)pro_yearly- Pro yearly ($290/yr, unlimited projects)
Autumn subscription plan identifier
Maximum number of projects user can create. Set to
-1 for unlimited (pro users)Unix timestamp (milliseconds) when trial period ends
Unix timestamp (milliseconds) when user was created
Unix timestamp (milliseconds) when user was last updated
Indexes
Query users by Stack Auth user IDFields:
[stackUserId]Legacy index for Clerk migration periodFields:
[clerkId]Query users by Autumn customer IDFields:
[autumnCustomerId]Operations
All user operations are defined inconvex/users.ts.
Get or Create User
Automatically called when users sign up or sign in.- Checks for existing user by
stackUserId - Creates new user with free tier (10 projects) if not found
- Updates
updatedAttimestamp for existing users
Get Subscription Info
Retrieve current user’s subscription details.Get Project Count
Count how many projects a user has created.Update Subscription
Sync subscription status from Autumn billing system.Start Trial
Begin a 7-day trial period for pro features.- Only available to users not already in trial or active subscription
- Sets
projectLimitto-1(unlimited) - Trial lasts 7 days (configurable via
TRIAL_DAYSconstant)
Cancel Trial
Cancel an active trial and return to free tier.- Reverts to free tier with 10 project limit
- Clears trial end date
Get Billing Status
Retrieve comprehensive billing information.Example Queries
Check if user can create projects
Get user by Stack Auth ID
Get user by Autumn Customer ID
Subscription Tiers
| Tier | Projects | Price | Status |
|---|---|---|---|
| Free | 10 | $0/mo | free |
| Pro Monthly | Unlimited | $29/mo | active/trialing |
| Pro Yearly | Unlimited | $290/yr | active/trialing |
Constants
Best Practices
The migration from Clerk to Stack Auth is ongoing. The
clerkId field will be removed in a future update.