This is a Next.js project bootstrapped with create-next-app.
The chat backend supports both OpenAI and Anthropic models.
Set these in .env.local:
# optional: force provider ("openai" | "anthropic")
AI_PROVIDER=openai
# optional: provider-agnostic model override (e.g. gpt-4.1-mini or claude-3-7-sonnet-latest)
AI_MODEL=
# OpenAI
OPENAI_API_KEY=
OPENAI_MODEL=gpt-4.1-mini
OPENAI_REASONING_SUMMARY=auto
OPENAI_REASONING_EFFORT=medium
# Anthropic
ANTHROPIC_API_KEY=
ANTHROPIC_MODEL=claude-3-7-sonnet-latestRouting behavior:
AI_PROVIDER=anthropicuses Anthropic.AI_PROVIDER=openaiuses OpenAI.- Without
AI_PROVIDER,claude-*models route to Anthropic; everything else routes to OpenAI.
You can run chat execution on Render while keeping the Next.js frontend on Vercel.
Set these on Vercel:
NEXT_PUBLIC_CHAT_API_BASE_URL=https://chat.rowsncolumns.ai
NEXT_PUBLIC_CHAT_API_PATH=/chatWhen NEXT_PUBLIC_CHAT_API_BASE_URL is set, the browser calls Render chat directly.
Render chat validates Better Auth sessions via /api/auth/get-session on your auth host.
Client payload includes only threadId, docId, and message.
Start command:
yarn chat:renderRender env vars:
PORT=10000
CHAT_RENDER_PATH=/chat
CHAT_SERVER_TIMEOUT_MS=1800000
CHAT_ALLOWED_ORIGINS=https://rowsncolumns.ai,https://www.rowsncolumns.ai,https://<your-vercel-domain>
CHAT_MODEL=gpt-5.4
CHAT_PROVIDER=openai
CHAT_REASONING_ENABLED=false
# Optional fixed server-side instructions (never sent by browser)
CHAT_SYSTEM_INSTRUCTIONS=
# Required auth backend URL for session introspection
# Falls back to BETTER_AUTH_URL when omitted.
CHAT_AUTH_BASE_URL=
CHAT_AUTH_BASE_PATH=/api/auth
# Reuse existing app runtime envs:
DATABASE_URL=
SHAREDB_URL=
OPENAI_API_KEY=
ANTHROPIC_API_KEY=
LANGCHAIN_API_KEY=
LANGCHAIN_TRACING_V2=
LANGCHAIN_PROJECT=Notes:
CHAT_ALLOWED_ORIGINSis enforced via CORS.- Keep
DATABASE_URLandSHAREDB_URLpointing to the same production backends used by the frontend app. - The legacy
/api/chatroute on Vercel can remain as fallback. - Render chat JSON request bodies are capped at
1MB.
Users receive daily free credits with a non-accumulating reset to 20.
- Free plan:
20daily credits (daily bucket resets, no rollover) - Pro:
$35/month,500monthly credits - Max:
$200/month,3500monthly credits - Top-up:
$50one-off purchase adds800credits
Credit accounting uses two buckets:
daily_free_remaining(free-only reset bucket)- durable paid
balance(plan grants + top-ups, no expiry)
Run credits migration:
yarn db:migrate:credits
yarn db:migrate:billingOptional admin allowlists (comma-separated) for manual refill access in Settings:
RNC_ADMIN_USER_IDS=
RNC_ADMIN_EMAILS=Stripe billing env vars:
STRIPE_SECRET_KEY=
STRIPE_WEBHOOK_SECRET=
# Optional override for customer portal config in Stripe
STRIPE_BILLING_PORTAL_CONFIGURATION_ID=
# Lookup keys from Stripe Prices
STRIPE_PRICE_LOOKUP_KEY_PRO_MONTHLY=pro_monthly
STRIPE_PRICE_LOOKUP_KEY_MAX_MONTHLY=max_monthly
STRIPE_PRICE_LOOKUP_KEY_TOPUP_50=topup_50Optional: provision the Stripe product + prices (idempotent by lookup key):
yarn stripe:provision:billing-catalogOptional: migrate existing Pro subscribers to the latest Pro price ($35) without proration:
# Dry run
yarn stripe:migrate:pro-35
# Apply changes
yarn stripe:migrate:pro-35 --applyShareDB server storage uses PostgreSQL.
Set in .env.local:
# Recommended: Postgres URL
SHAREDB_DATABASE_URL=
# Optional fallback used when SHAREDB_DATABASE_URL is missing
DATABASE_URL=
# ShareDB websocket server port
SHAREDB_PORT=8080
# Optional: set to false for local non-SSL Postgres
SHAREDB_REQUIRE_SSL=true
# Optional: maximum allowed serialized ShareDB document size in bytes.
# Default is 50MB (52428800). Set to 0 to disable the limit.
SHAREDB_DOC_MAX_BYTES=52428800Run ShareDB table migration:
yarn db:migrate:sharedb- External chat service (
/chat,/chat/stop,/chat/historyPOST fork): JSON request body limit is1MB. - ShareDB websocket transport (
ws): max inbound message payload is100MBby default unless overridden. - ShareDB document writes: server-enforced max serialized snapshot size is
50MBby default (SHAREDB_DOC_MAX_BYTES). - MCP spreadsheet resource payloads: truncated to
1MBby default (MCP_RESOURCE_MAX_BYTES). - Chat image uploads (
/api/chat/attachments/image): max file upload is8MB.
Track document ownership (doc_id -> user_id) in Postgres:
yarn db:migrate:documents
yarn db:migrate:document-shares
yarn db:migrate:document-share-permissions
yarn db:migrate:document-share-public-accessSet these auth env vars in .env.local (and in Vercel/Render):
BETTER_AUTH_URL=https://your-domain.com
BETTER_AUTH_SECRET=your-strong-secret
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
MICROSOFT_CLIENT_ID=
MICROSOFT_CLIENT_SECRET=
# Optional. Defaults to "common" for multi-tenant Microsoft sign-in.
MICROSOFT_TENANT_ID=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
# Email delivery (Resend)
RESEND_API_KEY=
RESEND_FROM_NAME=RowsnColumns AI
RESEND_FROM_EMAIL=noreply@rowsncolumns.ai
# New user admin notifications
# Optional override. Falls back to RNC_ADMIN_EMAILS when omitted.
RNC_ADMIN_NOTIFICATION_EMAILS=
# Weekly email check-ins (Inngest cron)
# Keep disabled until you are ready to send.
RNC_WEEKLY_EMAILS_ENABLED=false
# Defaults to Monday 09:00 UTC when omitted.
RNC_WEEKLY_EMAILS_CRON=TZ=UTC 0 9 * * 1
# Optional safety cap for sends per run.
RNC_WEEKLY_EMAILS_LIMIT=Generate/migrate Better Auth tables:
yarn db:migrate:authFor a fresh schema-only setup (no data migration), run:
yarn db:migrate:schemaFor full provider cutover steps (including optional template/user-document data migration scripts), see:
docs/postgres-provider-migration.md
First, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun devOpen https://localhost:3000 with your browser to see the result. OAuth sign-in (especially Safari) requires secure cookies, so dev now starts with HTTPS by default. Use https://localhost:3000.
If you need plain HTTP for debugging, run:
yarn dev:httpYou can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.
This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.