Prerequisites
Before deploying, ensure you have:- A Clerk account with API keys configured
- A Liveblocks account with secret and public keys
- (Optional) A Sentry account for error monitoring
- Node.js 18+ installed locally
- Git repository set up
Environment Variables
Your application requires the following environment variables:Required Variables
Optional Variables
The application uses Sentry for error tracking in production. While optional, it’s highly recommended for monitoring application health.
Build Process
The application uses Next.js 14 with the following build scripts defined inpackage.json:5-9:
Install Dependencies
@clerk/nextjs(v5.2.4) - Authentication@liveblocks/client,@liveblocks/react,@liveblocks/react-lexical(v2.3.0) - Real-time collaboration@sentry/nextjs(v8.18.0) - Error monitoringlexicaland@lexical/react(v0.16.1) - Rich text editor
Run Build
next build which:- Compiles TypeScript (with
ignoreBuildErrors: trueset innext.config.mjs:4-6) - Optimizes assets and images
- Uploads source maps to Sentry (if configured)
- Generates production-ready static and server files
Deployment Platforms
Vercel (Recommended)
Vercel is the recommended platform for Next.js applications and offers seamless deployment.Connect Repository
- Go to vercel.com and sign in
- Click “Add New Project”
- Import your Git repository
Configure Environment Variables
In the Vercel project settings, add all required environment variables:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYCLERK_SECRET_KEYLIVEBLOCKS_SECRET_KEYNEXT_PUBLIC_LIVEBLOCKS_PUBLIC_KEYSENTRY_DSN(optional)SENTRY_AUTH_TOKEN(optional)
Configure Build Settings
Vercel auto-detects Next.js projects. Verify these settings:
- Build Command:
npm run build - Output Directory:
.next - Install Command:
npm install - Node Version: 18.x or higher
The application is configured with Sentry integration (
next.config.mjs:12-45) that automatically uploads source maps during Vercel builds when SENTRY_AUTH_TOKEN is set.Other Platforms
You can also deploy to:- Netlify: Use the Next.js runtime plugin
- Railway: Connect your repo and set environment variables
- Self-hosted: Use
npm startafter building, or use a process manager like PM2
Post-Deployment Configuration
Clerk Redirect URLs
After deploying, update your Clerk application settings:- Go to Clerk Dashboard → Your Application → Settings
- Add your production URL to:
- Authorized Redirect URLs:
https://yourdomain.com - Sign-in URL:
https://yourdomain.com/sign-in - Sign-up URL:
https://yourdomain.com/sign-up
- Authorized Redirect URLs:
Image Optimization
The application is configured to allow images from Clerk (next.config.mjs:7-9):
Monitoring
If using Sentry:- Check the Sentry dashboard for any deployment errors
- Verify source maps are uploaded correctly
- Monitor error rates and performance metrics
Troubleshooting
Build Fails
- Verify all environment variables are set correctly
- Check that Node.js version is 18 or higher
- Review build logs for specific errors
Runtime Errors
- Ensure
LIVEBLOCKS_SECRET_KEYis set (lib/liveblocks.ts:4requires this) - Verify Clerk middleware is configured (
middleware.ts:1-7) - Check Sentry for detailed error traces
Authentication Issues
- Confirm Clerk redirect URLs match your production domain
- Verify
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYandCLERK_SECRET_KEYare correct - Check Clerk dashboard for API key status