Quickstart
Add auth + billing + feature gating to your app in under 10 minutes. We'll use HORIZON (a Next.js military intel dashboard) as the example throughout.
Step 1 β Initialize Corral
Start with npm create corral@latest, then run corral init in your project root. The CLI analyzes your
project structure, detects your framework and database, and scaffolds everything.
Install the generated dependencies:
npm install @corral/core @corral/next
What detection looks like (v0.4.1)
Detected framework: Next.js (App Router)
Detected database: PostgreSQL
Detected package manager: npm
Detected monorepo: no
Generated: auth routes, billing routes, AdminPanel, ProfilePage, AccountMenu, gates.tsx, auth-context.tsx, CORRAL.md, .corral/agent-checklist.json, llms-agent-prompt.md
Copy-paste prompt for your coding agent
Add Corral auth + billing to this app using v0.4.1 defaults.
Run: npm create corral@latest, then corral init.
Plans: free, pro ($49/mo, 14-day trial), enterprise (custom).
Gate ai_analysis to pro+ with blur preview for free users.
After changes run: corral validate --json and corral doctor --json.
Step 2 β Edit corral.yaml
The generated corral.yaml is a starting point. Customize it for
HORIZON's needs β add providers, define plans, gate features:
app:
name: HORIZON
url: https://horizon.mil
description: Military intelligence dashboard
# Auth providers β each one generates login UI + session handling
auth:
session_ttl: 7d
providers:
- google
- email:
magic_link: true
otp: false
- device # CLI auth for HORIZON's own CLI
# Billing plans β synced to Stripe with `corral stripe push`
plans:
free:
price: 0
description: Basic access. No credit card required.
pro:
price: 49
interval: month
description: Full analysis suite for analysts.
trial_days: 14
enterprise:
price: custom
description: Air-gapped deployment + custom SLA.
# Features β map to plans, define gate behavior
features:
basic_search:
plans: [free, pro, enterprise]
export_csv:
plans: [free, pro, enterprise]
ai_analysis:
plans: [pro, enterprise]
gate: blur # show blurred preview to free users
real_time_feed:
plans: [pro, enterprise]
gate: skeleton # show skeleton loader to free users
bulk_export:
plans: [enterprise]
gate: block # hard block with upgrade CTA
admin_console:
roles: [admin] # role-based, not plan-based
# Usage meters β track consumption, enforce limits
meters:
api_calls:
plans:
free: 500
pro: 10000
enterprise: unlimited
window: month
overage: block # or: charge, warn
export_rows:
plans:
free: 1000
pro: 100000
window: month
overage: warn
# Database β Corral shares your app's database
database:
adapter: prisma
url: env:DATABASE_URL
# Admin page
admin:
enabled: true
path: /admin
roles: [admin]
Step 3 β Run your app
Corral mounts its routes during your app's startup. No separate process needed β just run your app as normal:
Visit http://localhost:3000/api/auth/signin to see your login page. Corral has auto-generated UI for every configured provider.
Step 4 β Validate your config
corral validate checks your YAML against live state β providers,
plan definitions, feature gates, and database connectivity:
Step 5 β Sync to Stripe
If you added billing plans, push them to Stripe with one command.
This creates Products and Prices in Stripe and writes the price IDs back
into your YAML (or .env if you prefer):
NODE_ENV !== "production".
Use real Stripe test cards (4242 4242 4242 4242) to test the full checkout flow locally.
Step 6 β Gate your first feature
Now use Corral's components to gate the AI analysis panel in HORIZON.
The ai_analysis feature is configured with gate: blur,
so free-plan users see a blurred preview with an upgrade prompt:
import { FeatureGate } from '@/components/corral/FeatureGate'
import { AIAnalysisPanel } from '@/components/AIAnalysisPanel'
export default function DashboardPage() {
return (
<div className="dashboard">
<h1>Intelligence Overview</h1>
{/* Free users see a blurred preview + upgrade CTA */}
<FeatureGate feature="ai_analysis">
<AIAnalysisPanel />
</FeatureGate>
{/* This renders for everyone on free+ */}
<FeatureGate feature="basic_search">
<SearchPanel />
</FeatureGate>
</div>
)
}
That's it β FeatureGate reads the session server-side,
checks the plan, and applies the gate mode from your YAML.
No prop drilling, no context setup, no separate API call.
Step 7 β Deploy
Corral works with any deployment target that runs Node.js. Set your environment variables and deploy as normal:
| Variable | Required | Description |
|---|---|---|
CORRAL_SECRET |
Required | 32+ char random string for session signing |
DATABASE_URL |
Required | Your database connection string |
STRIPE_SECRET_KEY |
Billing | Stripe secret key (sk_live_...) |
STRIPE_WEBHOOK_SECRET |
Billing | Stripe webhook signing secret |
GOOGLE_CLIENT_ID |
OAuth | Google OAuth client ID |
GOOGLE_CLIENT_SECRET |
OAuth | Google OAuth client secret |
SMTP_URL |
SMTP connection string for magic links |