Skip to content

perafly.jsonc

The project's configuration file: build settings, redirects, rewrites, headers, cron jobs and first access.

On this page

The file

perafly.jsonc sits at the root of what you publish. It's JSON with comments. Perafly reads it when a version is finalized and turns it into the deployment's configuration; the file is published but never served. Framework detection and builds belong to the hosting provider; this file only overrides them.

perafly.jsonc
{
  "$schema": "https://perafly.com/schemas/perafly.json",
  "build": { "framework": "astro", "buildCommand": "npm run build", "outputDirectory": "dist" },
  "redirects": [{ "source": "/blog/:slug", "destination": "/posts/:slug", "permanent": true }],
  "headers": [{ "source": "/assets/(.*)", "headers": [{ "key": "Cache-Control", "value": "max-age=31536000" }] }],
  "crons": [{ "path": "/api/daily-report", "schedule": "0 6 * * *" }]
}

perafly init writes the file with its $schema, so your editor can check it as you type. The file never holds the project's id: which project a folder publishes to is in .perafly/project.json.

Keys

KeyTypeMeaning
$schemastringSchema address for editors: https://perafly.com/schemas/perafly.json.
buildobjectframework, installCommand, buildCommand, outputDirectory, rootDirectory (one project in a folder of a larger repository). Without build, the version is served as ready static output.
redirectsarray{ source, destination, permanent?, statusCode? }; statusCode is 301, 302, 307 or 308.
rewritesarray{ source, destination }.
headersarray{ source, headers: [{ key, value }] }.
cronsarray{ path, schedule }, at most 40. See cron jobs.
access"private" | "public"The project's first access. Read only on the project's first publish; later, change access in the dashboard or with perafly share.

redirects, rewrites and headers use the field names of Vercel's vercel.json and are passed through as written. Rules can't target /_files (storage) or /__perafly (the access gate); Perafly's own /_files/ rule comes before yours.

When the file is wrong

  • An invalid perafly.jsonc stops the version before it's deployed: finalize answers config_invalid and detail names the field and the reason. The CLI also checks the file before uploading.
  • vercel.json and now.json aren't accepted in a publish (config_file_not_allowed): move their rules here.

Building in a subfolder

perafly.jsonc
{
  "build": { "rootDirectory": "apps/web", "installCommand": "npm ci", "buildCommand": "npm run build", "outputDirectory": "dist" }
}