Static-Hosting

Host static React/Vite apps directly on Convex with built-in file storage, SPA routing, smart caching, and secure upload API.

Installation

npm install @convex-dev/static-hosting

About Static-Hosting

[integration guide](https://github.com/get-convex/static-hosting/blob/main/INTEGRATION.md)

๐Ÿš€ Simple deployment - Upload your built files directly to Convex storage
๐Ÿ”’ Secure by default - Upload API uses internal functions (not publicly accessible)
๐Ÿ”„ SPA support - Automatic fallback to index.html for client-side routing
โšก Smart caching - Hashed assets get long-term caching, HTML is always fresh with ETag support
๐Ÿงน Auto cleanup - Old deployment files are automatically garbage collected
๐Ÿ“ฆ Zero config - Works out of the box with Vite, Create React App, and other bundlers

Benefits

Use cases

how to host React app on Convex

The @convex-dev/static-hosting component lets you upload your built React app directly to Convex storage and serve it through HTTP actions. It handles SPA routing by automatically falling back to index.html for client-side routes.

static hosting with Convex backend

This component enables you to host your frontend and backend on the same Convex deployment. Upload your built static files to Convex storage and serve them through the component's HTTP actions, eliminating the need for separate hosting services.

Vite app deployment to Convex

The static-hosting component works out of the box with Vite builds. After running vite build, upload the dist folder contents to Convex storage using the component's secure upload API, and your app will be served with proper caching headers.

Frequently asked questions

Does the static-hosting component work with client-side routing?

Yes, @convex-dev/static-hosting automatically handles SPA routing by falling back to index.html when a requested file isn't found in storage. This ensures client-side routes work correctly with React Router, Vue Router, and similar libraries.

How does caching work with the static-hosting component?

The @convex-dev/static-hosting component implements smart caching where hashed assets (like bundle.abc123.js) get long-term cache headers, while HTML files are always served fresh with ETag support. This optimizes performance while ensuring users get the latest app version.

Is the upload API publicly accessible?

No, the @convex-dev/static-hosting component uses internal Convex functions for uploads, making them secure by default. Only your deployment process can upload files, not external clients or unauthorized users.

What bundlers does the static-hosting component support?

The @convex-dev/static-hosting component works with any bundler that generates static files, including Vite, Create React App, Next.js static export, Parcel, and Webpack. It requires zero configuration and handles standard build outputs automatically.

Links