convex.json and runtime options. This document covers the available configuration options for controlling backend behavior.
Project configuration (convex.json)
Theconvex.json file in your project root controls how your Convex backend is built and deployed.
Basic structure
Configuration options
Directory containing your Convex functions.Relative to your project root. Must end with a trailing slash.
List of npm packages to bundle as external dependencies.Packages listed here are loaded at runtime rather than bundled. This is required for packages that use Node.js native modules or dynamic imports.Example:
Node.js version to use in the runtime environment.Supported versions:
"18", "20"If not specified, uses the latest LTS version.Whether to generate a CommonJS API in
convex/_generated/.Set to true if you need to import generated code from CommonJS modules.Generate static type-safe API helpers in
convex/_generated/api.ts.Provides auto-completion and type-checking for function references.Generate static type definitions for your data model in
convex/_generated/dataModel.d.ts.Infers types from your schema definition.File type for generated code.Choices:
"ts", "js/dts""ts"- Generate TypeScript files"js/dts"- Generate JavaScript with separate type definition files
Include source code content in generated source maps.Useful for debugging in production, but increases bundle size.
TypeScript compiler to use for checking component implementations.Choices:
"tsc", "swc"WorkOS AuthKit configuration
Configuration for WorkOS AuthKit integration.Example:
Environment-specific configuration
Configure different settings for development, preview, and production environments.Development environment
Configuration for local development and dev deployments:Preview environment
Configuration for preview deployments:Production environment
Configuration for production deployments:Runtime environment variables
Access environment variables in your Convex functions usingprocess.env:
Node.js external packages
Some npm packages require special handling:Native modules
Packages with native Node.js modules must be marked as external:Dynamic imports
Packages that use dynamic imports at runtime:Best practices
- Version control - Commit
convex.jsonto version control - Minimal externals - Only mark packages as external when necessary
- Type safety - Keep
staticApiandstaticDataModelenabled - Node version - Explicitly specify
nodeVersionfor consistency - Environment separation - Use different configurations for dev, preview, and prod
Validation
The CLI validatesconvex.json on each deployment. Common errors:
- Invalid JSON syntax
- Unknown configuration keys
- Invalid values for known keys
- Missing required fields
npx convex dev --once to validate your configuration without deploying.