React · Updated 2026-09-14 · Demox team
How do you deploy a React build?
Direct answer: React source does not run on Demox. Run the production build, then upload the output folder. Vite React apps usually emit dist. Create React App emits build. Next.js only fits if you have a static export. Command examples: demox deploy ./dist or demox deploy ./build. Homepage, assets, and client-side routes should load from relative or root paths. API keys must not be in the bundle. For a Node API, export handler(request, env) and use demox functions push.
How to do it
- Step 1. Run the production build for your React toolchain.
- Step 2. Find the folder that contains index.html.
- Step 3. demox deploy that folder.
- Step 4. Test a hard refresh on a nested client route.
FAQ
Can I upload src/?
No. Upload the production build.
Create React App or Vite?
Both work after build. Point demox deploy at dist or build.
React 构建产物怎么发布?
先生产构建。Vite 一般是 dist,CRA 一般是 build。对那个目录执行 demox deploy。源码目录不能直接上。
按这个顺序做
- 01 按你的 React 工具链执行生产构建。
- 02 找到含 index.html 的目录。
- 03 对该目录执行 demox deploy。
- 04 对嵌套的前端路由做一次硬刷新检查。
常见问题
能上传 src/ 吗?
不能。上传生产构建产物。
Create React App 还是 Vite?
构建完成后都可以。把 demox deploy 指向 dist 或 build。