Skip to main content
Netlify provides a simple platform for deploying Evidence apps with automatic builds from your Git repository.

Prerequisites

  • An Evidence project in a Git repository (GitHub, GitLab, or Bitbucket)
  • A Netlify account
  • Your data sources configured and tested locally

Deployment Steps

1
Push Your Project to Git
2
Ensure your Evidence project is committed to a Git repository:
3
git init
git add .
git commit -m "Initial commit"
git remote add origin <your-repository-url>
git push -u origin main
4
Connect to Netlify
5
  • Log in to Netlify
  • Click Add new site > Import an existing project
  • Choose your Git provider (GitHub, GitLab, or Bitbucket)
  • Authorize Netlify to access your repositories
  • Select your Evidence repository
  • 6
    Configure Build Settings
    7
    Netlify should auto-detect your build settings. Verify or configure:
    8
    SettingValueBase directory(leave empty)Build commandnpm run sources && npm run buildPublish directorybuildFunctions directory(leave empty)
    9
    netlify.toml
    [build]
      command = "npm run sources && npm run build"
      publish = "build"
    
    [build.environment]
      NODE_VERSION = "18"
      NODE_OPTIONS = "--max-old-space-size=4096"
    
    10
    Add Environment Variables
    11
    If your data sources require credentials:
    12
  • In Netlify, go to Site settings > Environment variables
  • Add your environment variables with the EVIDENCE_ prefix
  • For database connections, add variables like:
    • EVIDENCE_SOURCE__[datasource]__host
    • EVIDENCE_SOURCE__[datasource]__database
    • EVIDENCE_SOURCE__[datasource]__user
    • EVIDENCE_SOURCE__[datasource]__password
  • 13
    Never commit credentials to your Git repository. Always use environment variables for sensitive data.
    14
    Deploy
    15
    Click Deploy site. Netlify will:
    16
  • Clone your repository
  • Install dependencies
  • Run npm run sources to query your data
  • Run npm run build to build the static site
  • Deploy the contents of the build directory
  • Configuration Options

    Custom Domain

    To use a custom domain:
    1. Go to Site settings > Domain management
    2. Click Add custom domain
    3. Follow the instructions to configure DNS

    Build Hooks

    Set up build hooks to trigger deployments:
    1. Go to Site settings > Build & deploy > Build hooks
    2. Click Add build hook
    3. Name your hook (e.g., “Scheduled rebuild”)
    4. Use the webhook URL to trigger builds via API or scheduled jobs

    Redirects and Rewrites

    Create a netlify.toml file in your project root:
    [build]
      command = "npm run sources && npm run build"
      publish = "build"
    
    [[redirects]]
      from = "/old-page"
      to = "/new-page"
      status = 301
    
    [[headers]]
      for = "/*"
      [headers.values]
        X-Frame-Options = "DENY"
        X-XSS-Protection = "1; mode=block"
    

    Continuous Deployment

    Netlify automatically rebuilds your site when you push to your repository:
    git add .
    git commit -m "Update dashboard"
    git push
    
    Monitor the build progress in the Netlify dashboard under Deploys.

    Troubleshooting

    Build Fails with Memory Error

    Increase the Node.js memory limit in netlify.toml:
    [build.environment]
      NODE_OPTIONS = "--max-old-space-size=8192"
    

    Build Command Not Found

    Ensure your package.json includes the build scripts:
    {
      "scripts": {
        "sources": "evidence sources",
        "build": "evidence build",
        "dev": "evidence dev"
      }
    }
    

    Data Source Connection Fails

    1. Verify environment variables are set correctly in Netlify
    2. Check that your data source is accessible from Netlify’s servers
    3. Review build logs for specific error messages
    4. Test locally with the same environment variables

    Build Takes Too Long

    Optimize your build:
    • Use --changed flag to build only modified queries: npm run sources -- --changed
    • Reduce the amount of data queried during build time
    • Consider pre-aggregating data in your database

    Next Steps

    Build docs developers (and LLMs) love