Configure the prev CLI using environment variables, flags, or a configuration file.

Configuration Methods

The CLI supports three ways to configure settings, listed by priority (highest first):

  • CLI Flags — Override everything for a single command
  • Environment Variables — Set defaults for your session or CI/CD
  • Configuration File — Persistent defaults
  • Environment Variables

    PREV_API_KEY

    Your API key for authentication.

    export PREV_API_KEY="your-api-key-here"

    PREV_API_URL

    Override the API endpoint (useful for self-hosted or development).

    export PREV_API_URL="https://api.prev.sh"

    Configuration File

    Create a .prev.yaml file in your home directory or project root:

    api_key: your-api-key-here
    api_url: https://api.prev.sh

    File Locations

    The CLI looks for configuration files in this order:

  • ./.prev.yaml — Project directory (highest priority)
  • ~/.prev.yaml — Home directory
  • CLI Flags

    Any configuration can be overridden with CLI flags:

    prev create . --api-key your-key --api-url https://api.prev.sh

    Priority Order

    When the same setting is defined in multiple places, this is the resolution order:

    CLI Flag  >  Environment Variable  >  Config File  >  Default Value

    For example, if PREV_API_KEY is set as an environment variable but you also pass --api-key as a flag, the flag value wins.

    CI/CD Configuration

    For CI/CD pipelines, we recommend using environment variables:

    GitHub Actions

    jobs:
      preview:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v4
          - name: Install prev CLI
            run: curl -fsSL https://prev.sh/install.sh | sh
          - name: Deploy preview
            env:
              PREV_API_KEY: ${{ secrets.PREV_API_KEY }}
            run: prev create .

    GitLab CI

    preview:
      script:
        - curl -fsSL https://prev.sh/install.sh | sh
        - prev create .
      variables:
        PREV_API_KEY: $PREV_API_KEY