This example demonstrates how to use the @convex-dev/static-hosting component
to host a React/Vite app directly on Convex.
From the root of the repository:
# Install dependencies and start dev server
npm install
npm run devThis starts:
- The Convex backend development server
- The Vite frontend development server
- A file watcher for rebuilding the component
Once you have a Convex deployment, build and upload the static files with the
CLI (it builds with the right VITE_CONVEX_URL, deploys the backend, and
uploads dist/):
# From the repo root
npm run deploy:staticYour app will then be available at https://your-deployment.convex.site.
convex/convex.config.ts- Imports and uses the static hosting componentconvex/staticHosting.ts- Exposes the deployment query for<UpdateBanner />src/- Example React application
- The component stores static files in its own Convex file storage
- The component's HTTP routes serve files with proper Content-Type and caching
- SPA fallback ensures client-side routing works correctly
- Each deployment gets a unique ID for atomic updates and garbage collection