> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opengame.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy a game built with a web framework

> Deploy a Three.js or React game built with Next.js, Vite, webpack, Parcel, Astro, SvelteKit or plain HTML. Any framework works once it builds static files.

OpenGame hosts the static files your build writes: `index.html` at the root of a folder, with the scripts, styles and assets it loads. Any framework or bundler that can write that folder works, so a game does not have to use Vite. What OpenGame cannot run is a server: server-side rendering on each request, API routes, server actions and middleware need a Node process, and a game on OpenGame has none.

`opengame init` reads your `package.json` and the framework's config, writes the build command and the output folder into `opengame.json`, and names the setting to change when the project is set to build a server.

| Framework | Build | Folder init uses | What to set |
| - | - | - | - |
| Vite, with React, React Three Fiber, Vue, Svelte or none | `vite build` | `dist/`, or `build.outDir` | No change. `base` may be `"./"` or left out |
| Next.js, App Router or Pages Router | `next build` | `out/`, or `distDir` | `output: "export"` in `next.config` |
| React with webpack, or a Create React App layout | `webpack` or `react-scripts build` | `build/` from the webpack config, or `dist/` | No change |
| Parcel | `parcel build src/index.html` | `dist/`, or `--dist-dir` | No change |
| Astro | `astro build` | `dist/`, or `outDir` | Keep Astro's default static output |
| SvelteKit | `vite build` | `build/`, or the adapter's `pages` | `@sveltejs/adapter-static` |
| Nuxt | `nuxt generate` | `.output/public/` | Use `nuxt generate`, not `nuxt build` |
| Plain HTML, with an import map or none | None | The project folder | No change |

We tested each framework except Nuxt on 17 Nov 2026 with a spinning-cube scene: Next.js 16, Vite 8 with React 19 and with React Three Fiber, webpack 5, Parcel 2, Astro 7 and SvelteKit 3, built, checked, served by the same game server players use, and played in Chrome.

## Next.js

A Next.js app builds a Node server unless you ask for a static export. Add `output: "export"` to `next.config`, and `next build` writes the site to `out/`:

```js next.config.mjs theme={"system"}
/** @type {import('next').NextConfig} */
const nextConfig = {
  output: "export",
  // next/image has no server to resize on, so serve the files as they are.
  images: { unoptimized: true },
};

export default nextConfig;
```

* **Render the scene in a client component.** Mark the component that holds the canvas with `"use client"` and create the renderer in `useEffect`, so it runs in the browser and not during the build. React Three Fiber's `<Canvas>` works the same way.
* **No `basePath`.** Your game is served at the root of a dedicated address, so a `basePath` such as `"/game"` makes each page ask for files that are not there. If another host needs it, set it from an environment variable that only that host's build sets.
* **`trailingSlash` either way.** Links to `/about` find `about.html`, and with `trailingSlash: true` they find `about/index.html`.
* **What a static export cannot do:** anything that needs a server at request time, including route handlers that read the request, server actions, cookies, rewrites, redirects, `proxy` (middleware) and dynamic routes without `generateStaticParams`. Next.js lists them in its [static exports guide](https://nextjs.org/docs/app/guides/static-exports#unsupported-features). Move that work into the game, or onto a server of your own that the game calls over `https:`.

```bash theme={"system"}
opengame init .
opengame check . --build
```

`init` writes `"output": "out"`. A Next.js project without `output: "export"` fails with `static_build_required`, which names the line to add.

## React and React Three Fiber

A React game built with Vite writes `dist/`, the same as any Vite project. React Three Fiber needs no extra setting: `<Canvas>` creates the renderer in the browser.

With webpack, `init` reads `output.path` from `webpack.config.js` when it is written as `path.resolve(__dirname, "build")`, and uses `dist/` otherwise. An `index.html` that html-webpack-plugin uses as a template, such as `public/index.html`, is not taken for the build. A Create React App project writes `build/`.

## Astro, SvelteKit and Nuxt

* **Astro** builds static pages by default and writes `dist/`. `output: "server"` needs a server adapter, so `init` refuses it. Put the game code in a `<script>` in the page, or in a client island.
* **SvelteKit** needs `@sveltejs/adapter-static` and `export const prerender = true` in the root `+layout.js`. For a game that renders only in the browser, pass `fallback: "index.html"` to the adapter instead. `init` uses `build/`, or the adapter's `pages` option.
* **Nuxt** writes a static site to `.output/public/` with `nuxt generate`. `nuxt build` makes a server, so `init` refuses it.

`init` refuses a base path in Astro and SvelteKit, as it does in Next.js and Vite: Astro's `base`, SvelteKit's `paths.base` and Vite's `base`, when it is a path such as `"/my-game/"`. `"./"`, `"/"` and a full `https:` address are fine.

## Plain HTML and import maps

A folder with `index.html` and no build needs no settings. An import map can point `three` at a copy in the folder or at a CDN:

```html index.html theme={"system"}
<script type="importmap">
  { "imports": { "three": "./vendor/three.module.js" } }
</script>
<script type="module" src="./main.js"></script>
```

Copy `three.module.js` and `three.core.js` from `node_modules/three/build/` into the folder, so the game loads without another host. A CDN address such as `https://cdn.jsdelivr.net/npm/three@0.180.0/build/three.module.js` works too under the current [runtime contract](https://docs.opengame.io/reference/runtimes.md), which allows scripts from any `https:` host, but the game then stops working when that CDN is slow or down. A threaded build also needs the CDN to send CORS headers.

## Pages and links

A game's frame can move between pages of the same build, in the private preview and once published. OpenGame resolves each page address the way static hosts do:

| Address | File |
| - | - |
| `/` | `index.html` |
| `/menu/` | `menu/index.html` |
| `/about` | `about`, then `about.html` |
| `/menu`, when `menu/index.html` exists | A redirect to `/menu/`, so the page's relative links resolve inside that folder |

There is no fallback to `index.html` for an address with no file, so a client-side router has to start from `/`.

## When check reports a problem

* **`static_build_required`**: the framework is set to build a server, or to serve under a base path. The message names the setting.
* **`missing-import`** naming paths under a folder that is not in your build, such as `game/_next/...`: a base path or an asset prefix the config sets in a way `init` cannot read. Remove it for the OpenGame build.
* **`bare-import`**: a page imports a package by name, such as `import "three"`. Upload the folder your build writes, not your source, or add an import map.
* **The output folder does not exist**: the build wrote somewhere else. Set `build.output` in `opengame.json` to the folder with `index.html` in it.

[Package a game](https://docs.opengame.io/guides/packaging.md) lists the checks, and [Three.js](https://docs.opengame.io/engines/threejs.md) has the renderer, decoder and SDK settings, which apply with any framework.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.