A production-ready SvelteKit application configured for deployment on Convox.
SvelteKit is the official application framework for Svelte, providing a full-stack development experience with server-side rendering, routing, and build optimizations. This example demonstrates how to deploy a SvelteKit app on Convox with automatic SSL, load balancing, and zero-downtime deployments.
Deploy to Convox Cloud for a fully-managed platform experience, or to your own Convox Rack for complete control over your infrastructure. Either way, you'll get automatic SSL, load balancing, and zero-downtime deployments out of the box.
- Modern Web Framework - Built with SvelteKit for optimal performance and developer experience
- Server-Side Rendering - Full SSR support with SvelteKit's adapter-node
- Interactive Components - Includes demo components showcasing Svelte's reactive capabilities
- Container-Ready - Optimized Docker configuration for production deployments
- Production Configured - Environment-based configuration with secure defaults
- Health Monitoring - Built-in health check endpoint for reliability
- Auto-Scaling Ready - Configured for horizontal scaling based on load
- Tailwind CSS - Pre-configured with Tailwind for rapid UI development
-
Create a Cloud Machine at console.convox.com
-
Create the app:
convox cloud apps create svelte-app -i your-machine-name- Deploy the app:
convox cloud deploy -a svelte-app -i your-machine-name- View your app:
convox cloud services -a svelte-app -i your-machine-nameVisit your URL to see the SvelteKit app running!
- Create the app:
convox apps create svelte-app- Deploy the app:
convox deploy -a svelte-app- View your app:
convox services -a svelte-appVisit your URL to see the SvelteKit app running!
The example SvelteKit application includes:
- Home Page - Welcome page with interactive counter component
- About Page - Static page demonstrating SSR capabilities
- Sverdle Game - A Wordle clone showcasing form handling and server-side logic
- Reactive Components - Demonstrates Svelte's reactive features and animations
# Get the service URL
convox services -a svelte-app
# Test the application
curl https://web.svelte-app.cloud.convox.com/
# Test the about page
curl https://web.svelte-app.cloud.convox.com/about
# Access the Sverdle game
curl https://web.svelte-app.cloud.convox.com/sverdleConfigure your application using environment variables:
convox env set \
NODE_ENV=production \
PUBLIC_API_URL=https://api.example.com \
-a svelte-appAdjust the number of running processes and resources:
# Scale to 3 instances with specific resources
convox scale web --count 3 --cpu 512 --memory 1024 -a svelte-appOr configure autoscaling in your convox.yml:
services:
web:
build: .
port: 3000
scale:
count: 1-5
cpu: 256
memory: 512
targets:
cpu: 70
memory: 80- Install dependencies:
npm install- Run development server:
npm run dev
# or start with auto-open
npm run dev -- --openThe app will be available at http://localhost:5173
- Build for production:
npm run build- Preview production build:
npm run previewUse Convox to run the application locally with Docker:
convox startThis will build and run the application in a local Docker environment that mimics production.
.
├── src/
│ ├── app.html # HTML template
│ ├── app.css # Global styles with Tailwind
│ ├── routes/ # SvelteKit routes
│ │ ├── +page.svelte # Home page
│ │ ├── +layout.svelte # Root layout
│ │ ├── about/ # About page
│ │ └── sverdle/ # Sverdle game
│ └── lib/ # Shared components and utilities
├── static/ # Static assets
├── Dockerfile # Docker configuration
├── convox.yml # Convox deployment configuration
├── package.json # Node.js dependencies
├── svelte.config.js # SvelteKit configuration
└── vite.config.ts # Vite bundler configuration
The application uses a simple, efficient Docker configuration:
- Base Image: Node.js 22 Alpine for minimal size
- Build Stage: Compiles the SvelteKit application
- Runtime: Runs the production build with Node.js
This results in small, secure production images optimized for fast deployments.
Cloud:
convox cloud logs -a svelte-app -i your-machine-nameRack:
convox logs -a svelte-appThe application includes a built-in health check endpoint:
curl https://your-svelte-app-url/- Use Environment Variables: Never hardcode secrets or configuration
- Enable HTTPS: Always use HTTPS in production (Convox handles this automatically)
- Set Resource Limits: Configure appropriate CPU and memory limits
- Use Health Checks: Ensure your application can be monitored
- Optimize Builds: Keep Docker images small with production dependencies only
- Regular Updates: Keep SvelteKit and dependencies updated
Check that the application is binding to the correct port:
convox logs -a svelte-app --filter "listening"Verify environment variables:
convox env -a svelte-appIf the build fails, check the build logs:
convox builds logs BUILD_ID -a svelte-appCommon issues:
- Ensure all required dependencies are in package.json
- Check that the Dockerfile references the correct Node.js version
- Verify the build script in package.json is correct
Monitor resource usage:
convox ps -a svelte-appConsider scaling up if CPU or memory usage is high:
convox scale web --cpu 1000 --memory 2048 -a svelte-appAdd your custom domain:
convox services -a svelte-app
# Note the router domain, then create a CNAME to itTo add a PostgreSQL database:
- Update your
convox.yml:
resources:
database:
type: postgres
options:
storage: 10
version: 13
services:
web:
build: .
port: 3000
resources:
- database- Access the database URL in your application:
// In your SvelteKit app
const databaseUrl = process.env.DATABASE_URL;Add a worker service to your convox.yml:
services:
web:
build: .
port: 3000
worker:
build: .
command: node worker.js
scale:
count: 1
cpu: 256
memory: 512For serving static assets efficiently, you can configure caching headers and CDN integration:
services:
web:
build: .
port: 3000
environment:
- PUBLIC_CDN_URL=${CDN_URL}This example uses @sveltejs/adapter-node for Node.js deployments. The configuration in svelte.config.js is optimized for containerized environments.
SvelteKit distinguishes between private and public environment variables:
- Private variables (like API keys) are only available server-side
- Public variables (prefixed with
PUBLIC_) are available in both server and client code
The production build creates:
- Server-side code in the
builddirectory - Client-side assets optimized for performance
- Automatic code-splitting for optimal loading
- SvelteKit Documentation
- Svelte Documentation
- Svelte Tutorial
- Convox Documentation
- Tailwind CSS Documentation
- Svelte Community: Discord | Reddit
- Convox Support: cloud-support@convox.com
- GitHub Issues: Create an issue