Skip to main content

Framework guides

Supported runtimes

Sevalla supports the following JavaScript runtimes:
  • Node.js: The most widely used runtime for server-side JavaScript.
  • Deno: A secure, modern runtime with built-in tooling.
  • Bun: A fast, all-in-one JavaScript runtime, bundler, and package manager.

Supported package managers

Sevalla fully supports the major JavaScript package managers (npm, Yarn, and pnpm). You can define the package manager for your project in the packageManager field of package.json, and Sevalla will automatically use it during builds. Within your package.json, it’s important to provide accurate values for the engines and packageManager fields. Both Buildpacks and Nixpacks read and respect these settings to ensure consistent builds.
  • engines defines the required versions of Node.js and npm/yarn/pnpm that your project depends on. This helps prevent runtime mismatches and ensures your application runs in a compatible environment.
  • packageManager specifies which package manager, and which exact version, should be used. This ensures consistent dependency installation across local development, CI/CD, and production.
These fields together help maintain predictable builds and avoid issues caused by mismatched runtimes or conflicting lockfiles. For example, to use Node.js 18+, npm 9+, and ensure all environments use the same npm version:
...
  "engines": {
    "node": ">=18.17.0 <21",
    "npm": ">=9"
  },

  "packageManager": "[email protected]"
}

Best practices

Stateless

Make your applications stateless. With stateless applications, you can use horizontal scaling, which means you can run multiple instances simultaneously because no instance depends on its own in-memory data. Stateless applications are also safer to deploy and more reliable because every instance behaves identically, and shared data lives outside the app itself. To ensure your application can scale reliably and support zero-downtime deployments, all stateful data must be stored outside the application container. Follow these best practices:
  1. Use external session storage: Store user sessions in a shared system, allowing any application instance to serve any request. You can host a Redis database in Sevalla and use it as your external session store.
  2. Use external caching for arbitrary data: Do not cache data in memory within the application.
    Instead, use a Redis instance hosted in Sevalla to store cached values that need to be shared across instances.
  3. Store uploads outside the application (stateless file handling): User uploads should never be stored on the app’s local file system. Use Sevalla’s object storage for hosting files, images, and videos.
  4. Use database connection pooling over the internal private network: If your database is hosted in Sevalla, connect via the internal private network to reduce latency and improve security. Use connection pooling to efficiently manage database connections across multiple instances.
  5. Use environment variables for configuration: All environment-specific configuration (API keys, secrets, feature flags, etc.) should be stored in environment variables, not in code or files.

Object storage

Sevalla’s object storage, powered by Cloudflare R2, provides secure, scalable, and persistent storage for files in your JavaScript or TypeScript app. Its S3-compatible API makes it easy to manage uploads, downloads, and assets, ideal for user uploads, backend outputs, or serving media, while keeping your data private and reliably accessible. For step-by-step instructions on integrating object storage into your JavaScript app, see our Object storage integration guide.

Horizontal scaling

Use the following best practices for scaling your JavaScript application on Sevalla:
  • Keep your app stateless – Avoid in-memory sessions or local file storage to ensure reliability and scalability.
  • Leverage external services – Use managed databases, Redis, or S3 for data persistence and caching.
  • Enable auto-scaling – Allow your application to handle fluctuating traffic efficiently.
  • Maintain high availability – Start with at least two instances to ensure redundancy.
  • Monitor resource usage – Track CPU and memory to optimize instance count and performance.

Redis

We recommend integrating Redis with your JavaScript application on Sevalla to boost performance and scalability. By storing frequently accessed data in memory, Redis reduces database load and accelerates response times. It also enables real-time features, such as live notifications or chat, and supports robust background job processing, making it easier to handle high-traffic scenarios and improve overall application responsiveness. For step-by-step instructions on integrating Redis into your JavaScript app, see our Redis integration guide.

Health checks

Configure zero-downtime deployments with health checks. Health checks ensure new instances are ready before receiving traffic, enabling rolling deployments without interruptions.

Graceful shutdown

Implement graceful shutdown handling to ensure your application completes in-flight requests and properly cleans up resources when containers are stopped.

Deployment pipelines

Use deployment pipelines to test changes in a staging environment before promoting them to production, thereby avoiding the introduction of regressions.