Configure the stats database
Keep dashboard history on persistent storage, or disable stats while retaining the cache.
The server records stats in a database through Nitro’s database layer. It writes after each response, so stats never slow the cache down, and a failed write never fails a cache request. Without a database, the cache works the same and the dashboard explains that stats are off.
| Platform | Database |
|---|---|
| Cloudflare Workers | A D1 database bound as STATS_DB. Wrangler creates it, named turborepo-cache-stats, on the first deploy. |
| Node.js and Deno | Nitro’s default SQLite database, a file at .data/db.sqlite in the working directory. Keep it on a persistent volume. For Bun, configure the bun-sqlite connector. |
| Vercel, Netlify, AWS Lambda | None that works. Their file systems are read-only, so the SQLite default can’t open its file and stats stay off. Configure a hosted database. |
D1’s free plan allows 100,000 rows written a day. The server writes about four rows per turbo run and one per artifact upload or download. See D1 pricing for the paid limits.
Configure a hosted database
Set the default connection in apps/api/nitro.config.ts. Use a hosted database on serverless platforms, whose file systems don’t keep files between requests. For example, with Turso:
// Add database to the existing defineConfig call.
export default defineConfig({
database: {
default: {
connector: 'libsql',
options: { url: process.env.TURSO_URL, authToken: process.env.TURSO_AUTH_TOKEN },
},
},
});
The server creates its tables on first use. Its queries run on SQLite and PostgreSQL, so choose a SQLite, libSQL, PostgreSQL, Neon, or PGlite connector. MySQL isn’t supported.
Rebuild and redeploy after changing database settings. Check /stats and the server logs to confirm that stats are enabled. See Troubleshooting if they remain unavailable.
Turn stats off
On Cloudflare, remove the d1_databases entry from apps/api/wrangler.jsonc. Elsewhere, set database: {} in apps/api/nitro.config.ts.
Rebuild and redeploy. The dashboard then reports that stats are disabled, and artifact caching keeps working.