Skip to main content

Overview

Vercel provides the best deployment experience for Next.js-based Fumadocs applications, with zero-configuration deployment, automatic HTTPS, and global CDN distribution.

Quick Start

1
Install Vercel CLI
2
npm i -g vercel
3
Deploy
4
vercel
5
Follow the prompts to link your project and deploy.
6
Production Deployment
7
vercel --prod

Git Integration

For automatic deployments on every push:
1
Import Project
2
  • Go to Vercel Dashboard
  • Click “Add New…” → “Project”
  • Import your Git repository (GitHub, GitLab, Bitbucket)
  • 3
    Configure Build Settings
    4
    Vercel auto-detects Next.js projects. Default settings:
    5
  • Framework Preset: Next.js
  • Build Command: next build
  • Output Directory: .next
  • Install Command: Automatically detected
  • 6
    Deploy
    7
    Click “Deploy” - Vercel will build and deploy your site.

    Configuration

    vercel.json

    Optional configuration file for advanced settings:
    vercel.json
    {
      "buildCommand": "npm run build",
      "devCommand": "npm run dev",
      "installCommand": "npm install",
      "framework": "nextjs",
      "outputDirectory": ".next"
    }
    

    Environment Variables

    Set environment variables in the Vercel dashboard:
    1. Go to Project Settings → Environment Variables
    2. Add variables for:
      • NEXT_PUBLIC_* - Client-side variables
      • DATABASE_URL - Server-side secrets
      • API_KEY - Private API keys
    Or use the Vercel CLI:
    vercel env add NEXT_PUBLIC_SITE_URL
    

    Custom Domains

    Add custom domains in Project Settings → Domains:
    1
    Add Domain
    2
    Enter your domain name (e.g., docs.example.com)
    3
    Configure DNS
    4
    Point your domain to Vercel:
    5
    Using A Record:
    6
    A @ 76.76.21.21
    
    7
    Using CNAME:
    8
    CNAME docs cname.vercel-dns.com
    
    9
    SSL Certificate
    10
    Vercel automatically provisions SSL certificates.

    Build Optimization

    Next.js Configuration

    Optimize your next.config.js for Vercel:
    next.config.mjs
    import { createMDX } from 'fumadocs-mdx/next';
    
    const withMDX = createMDX();
    
    /** @type {import('next').NextConfig} */
    const config = {
      reactStrictMode: true,
      
      // Optimize logging
      logging: {
        fetches: {
          fullUrl: true,
        },
      },
    
      // External packages for serverless
      serverExternalPackages: [
        'ts-morph',
        'typescript',
        'shiki',
        '@takumi-rs/image-response',
      ],
    
      // Remote image patterns
      images: {
        remotePatterns: [
          {
            protocol: 'https',
            hostname: 'avatars.githubusercontent.com',
          },
        ],
      },
    };
    
    export default withMDX(config);
    

    Bundle Analysis

    Analyze your bundle size:
    npm install --save-dev @next/bundle-analyzer
    
    next.config.mjs
    import createBundleAnalyzer from '@next/bundle-analyzer';
    import { createMDX } from 'fumadocs-mdx/next';
    
    const withAnalyzer = createBundleAnalyzer({
      enabled: process.env.ANALYZE === 'true',
    });
    
    const withMDX = createMDX();
    
    const config = {
      // ... your config
    };
    
    export default withAnalyzer(withMDX(config));
    
    Run analysis:
    ANALYZE=true npm run build
    

    Caching Strategy

    Optimize caching for static assets:
    next.config.mjs
    const config = {
      async headers() {
        return [
          {
            source: '/static/:path*',
            headers: [
              {
                key: 'Cache-Control',
                value: 'public, max-age=31536000, immutable',
              },
            ],
          },
        ];
      },
    };
    

    Search Configuration

    Built-in Search (Orama)

    The default Orama search works out of the box on Vercel:
    app/api/search/route.ts
    import { allDocs } from '@/.source';
    import { createSearchAPI } from 'fumadocs-core/search/server';
    
    const api = createSearchAPI('advanced', {
      indexes: allDocs.map((page) => ({
        id: page.url,
        title: page.data.title,
        description: page.data.description,
        url: page.url,
        structuredData: page.data.structuredData,
      })),
    });
    
    export const GET = api.GET;
    export const POST = api.POST;
    
    For larger documentation sites, use Algolia:
    npm install algoliasearch
    
    Set environment variables:
    vercel env add ALGOLIA_APP_ID
    vercel env add ALGOLIA_SEARCH_API_KEY
    vercel env add ALGOLIA_WRITE_API_KEY
    
    See Algolia Integration for setup.

    Performance Optimization

    Edge Functions

    Use Edge Runtime for faster response times:
    app/api/search/route.ts
    export const runtime = 'edge';
    
    export async function GET(request: Request) {
      // ... your code
    }
    
    Fumadocs core features work on Edge Runtime, but some dependencies (like TypeScript compilation for API docs) require Node.js runtime.

    Incremental Static Regeneration (ISR)

    Regenerate pages on-demand:
    app/docs/[...slug]/page.tsx
    export const revalidate = 3600; // Revalidate every hour
    
    export default function Page({ params }: { params: { slug: string[] } }) {
      // ... your page component
    }
    

    On-Demand Revalidation

    Revalidate specific pages via API:
    app/api/revalidate/route.ts
    import { revalidatePath } from 'next/cache';
    import { NextRequest, NextResponse } from 'next/server';
    
    export async function POST(request: NextRequest) {
      const { path } = await request.json();
      
      if (!path) {
        return NextResponse.json({ error: 'Missing path' }, { status: 400 });
      }
    
      try {
        revalidatePath(path);
        return NextResponse.json({ revalidated: true, path });
      } catch (error) {
        return NextResponse.json({ error: 'Error revalidating' }, { status: 500 });
      }
    }
    
    Trigger revalidation:
    curl -X POST https://your-site.vercel.app/api/revalidate \
      -H 'Content-Type: application/json' \
      -d '{"path":"/docs/some-page"}'
    

    Monorepo Support

    For monorepo projects:
    vercel.json
    {
      "buildCommand": "cd ../.. && npm run build --filter=docs",
      "installCommand": "npm install --prefix=../..",
      "framework": "nextjs"
    }
    
    Or configure in Vercel Dashboard:
    1. Project Settings → General
    2. Set Root Directory to your docs package (e.g., apps/docs)
    3. Enable Include source files outside of the Root Directory

    Preview Deployments

    Vercel creates preview deployments for every push:
    • Production: Deploys from main/master branch
    • Preview: Deploys from feature branches and pull requests
    Configure branch deployments:
    1. Project Settings → Git
    2. Set Production Branch
    3. Enable/disable preview deployments

    CI/CD Integration

    GitHub Actions

    Deploy via GitHub Actions:
    .github/workflows/deploy.yml
    name: Deploy to Vercel
    
    on:
      push:
        branches: [main]
    
    jobs:
      deploy:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v4
          
          - name: Install Vercel CLI
            run: npm install -g vercel
          
          - name: Pull Vercel Environment
            run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
          
          - name: Build Project
            run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
          
          - name: Deploy to Vercel
            run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
    
    Set VERCEL_TOKEN in GitHub repository secrets.

    Troubleshooting

    Build Timeouts

    If builds exceed time limits:
    1. Optimize dependencies (remove unused packages)
    2. Enable caching in next.config.js
    3. Consider splitting large docs into separate projects
    4. Use static export for faster builds

    Memory Issues

    Increase Node.js memory:
    package.json
    {
      "scripts": {
        "build": "NODE_OPTIONS='--max-old-space-size=4096' next build"
      }
    }
    

    Function Size Limits

    If serverless functions exceed size limits:
    next.config.mjs
    const config = {
      serverExternalPackages: [
        'large-package-name',
      ],
    };
    

    Cold Starts

    Reduce cold start times:
    1. Minimize serverless function size
    2. Use Edge Runtime where possible
    3. Enable ISR for frequently accessed pages
    4. Consider static export for pure documentation

    Analytics

    Enable Vercel Analytics:
    npm install @vercel/analytics
    
    app/layout.tsx
    import { Analytics } from '@vercel/analytics/react';
    
    export default function RootLayout({ children }: { children: React.ReactNode }) {
      return (
        <html>
          <body>
            {children}
            <Analytics />
          </body>
        </html>
      );
    }
    
    View analytics in Vercel Dashboard → Analytics.

    Next Steps

    Build docs developers (and LLMs) love