Deploy a Vite + React Application
Build a Vite + React single-page application (SPA) into static production files (dist/) and deploy it to your Linux server.
On each deploy, Devopness installs dependencies, runs your Vite build inside a timestamped release folder (for example, ~/my-vite-app/releases/2026-06-15 13:45:10), and updates ~/my-vite-app/current to point to the latest release.
Goal
Compile a Vite + React repository into static HTML, CSS, and JavaScript assets (dist/) and serve the application on a Linux server.
Prerequisites
- A Devopness project and environment
- A connected Linux server with HTTP (
80) and HTTPS (443) ports open - A connected Git source provider (GitHub, GitLab, or Bitbucket) containing your Vite + React repository
- Your credential can read the target repository
Deploy options
When creating or configuring your application in Devopness, set these fields:
- Programming Language / Runtime: Select Node.js
- Build Command: Set to
npm ci && npm run build(ornpm install && npm run buildifpackage-lock.jsonis not committed) - Root Directory: Leave as
/unless your package manager file (package.json) is inside a subfolder
Build-time environment variables (optional)
Vite embeds variables prefixed with VITE_ into your JavaScript bundle during npm run build.
- Add a
.envconfiguration file to your application with yourVITE_*keys (for example,VITE_API_URL=https://example.com) - Deploy again after adding or editing
.envso Vite compiles the updated values intodist/
To create the .env file, see Add a File.
Using Devopness MCP
Try this prompt in Devopness MCP:
Use Devopness MCP to create an application in https://app.devopness.com/projects/{project_id}/environments/{environment_id} and deploy <repo_url> following guidelines from https://devopness.com/docs/applications/deploy-vite-react-applicationIncoming webhook creation is API-only, not available through MCP. Use the API reference and Create an Incoming Webhook guide. For GitHub, set secret_header_name to X-Hub-Signature-256.
Verify
You are done when:
- The deploy action reaches
completed, notfailedor stuckpending ~/application-name/current/distcontains your compiledindex.htmland static asset files- Your application loads in a browser at your server's IP address or domain name
- Client-side SPA routes (such as
/about) load without returning a404error
After deploy
- Add a Virtual Host in the same environment and configure routing to serve static files directly from your application's
distdirectory - Configure an incoming webhook on your deploy pipeline to trigger deploys automatically on
git push
See Add a Virtual Host for static directory routing details.
Common issues
Build fails with out-of-memory error on small VMs
Building Vite on servers with 1 GB RAM (such as AWS t3.micro or GCP e2-micro) can exhaust memory. Devopness SSH sessions log in as the non-root devopness user, so connect via SSH and run with sudo (or as root) to add 2 GB of swap space before deploying:
sudo fallocate -l 2G /swapfile && sudo chmod 600 /swapfile && sudo mkswap /swapfile && sudo swapon /swapfileUpdated environment variables do not appear after deploy
Vite injects VITE_* variables at build time, not runtime. Confirm your keys start with VITE_ in .env and trigger a new deploy.
Deploy succeeds but the site shows "Configured by Devopness!"
Confirm a Virtual Host is configured for your server IP or domain name and its routing points to your application's dist directory, then deploy again.
What to do next
Required permissions
To follow this guide, you need the following permissions in the target environment.
| Resource Type | Required Permission |
|---|---|
| Application | Deploy |
For instructions on how to grant user permissions to an environment, please follow the guide Add a team to an environment.