Skip to content

Search the guides, deployment pages, and API reference.

GitHub Pages

GitHub Pages serves static files only. There is no server runtime. A client-only app in SPA mode works, and so does a server-rendered app whose pages are all prerendered at build time. (Need a server at runtime? Cloudflare, Netlify, Vercel, and Railway all have one.)

A client-only app runs remix() in SPA mode: server: false turns off the server environment, so there is nothing to build to dist/ssr and nothing serving requests in dev. The plugin still gives you component hot module replacement, so it is worth keeping in a static build.

Setup

index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>My Remix App</title>
<script type="module" src="/app/main.tsx"></script>
</head>
<body>
<div id="app"></div>
</body>
</html>
app/main.tsx
import { createRoot, on, type Handle } from "remix/component";
function App(handle: Handle) {
let count = 0;
return () => (
<button
mix={[
on("click", () => {
count++;
handle.update();
}),
]}
>
Count: {count}
</button>
);
}
createRoot(document.getElementById("app")!).render(<App />);
tsconfig.json
{ "compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "remix/component" } }
vite.config.ts
import { remix } from "pitlane/vite-plugin-remix";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [remix({ server: false })],
});

pitlane/vite-plugin-remix comes from the pitlane package. The github-pages template depends on the scoped @pitlane/vite-plugin-remix package, so add pitlane before switching the import. If only vite.config.ts imports it, install it as a dev dependency with npm add -D pitlane. The Pitlane package guide lists the remix and vite versions it requires and the standalone @pitlane/vite-plugin-remix alternative.

The two GitHub Pages quirks

Base path. A project site is served from https://<user>.github.io/<repo>/, so Vite needs the base configured or every asset URL 404s:

vite.config.ts
export default defineConfig({
base: "/<repo>/",
plugins: [remix({ server: false })],
});

User/organization sites (<user>.github.io) and custom domains serve from / and skip this.

SPA fallback. Pages has no rewrite rules; the convention is a 404.html that is a copy of index.html, so deep links boot the app:

Terminal window
vite build && cp dist/index.html dist/404.html

Prerendered sites

SPA mode is one way to fill a static host. The other is a server-rendered app whose pages are all static: remix({ prerender }) renders them to HTML during vite build, and Pages serves a real document per path instead of one shell.

vite.config.ts
export default defineConfig({
plugins: [remix({ prerender: true })],
});

true covers every static path in the route map, read from the server entry's routes export; an explicit list, a function, or spider: true covers the rest. Pages has no server, so every URL the site answers must be in the output. See where the paths come from.

Each path lands as <path>/index.html under dist/client, beside the hashed assets, so the workflow below uploads dist/client instead of dist and skips the 404.html copy: deep links hit real files, and a URL outside the prerendered set is a real 404.

The base path quirk holds, spelled differently: declare the routes under the base and set Vite's base to match. Output is written relative to the base. A route on /<repo>/blog still writes blog/index.html, because Pages mounts the uploaded directory at /<repo>/:

app/routes.ts
import { get, route } from "remix/routes";
export let routes = route({
home: "/<repo>",
blog: get("/<repo>/blog"),
});

Deploy with GitHub Actions

GitHub Pages deploys through Actions. There is no separate CLI deploy. Enable it once under Settings → Pages → Source: GitHub Actions, then:

.github/workflows/deploy.yml
name: Deploy
on:
push:
branches: [main]
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- run: npm ci
- run: npm run build && cp dist/index.html dist/404.html
- uses: actions/configure-pages@v5
- uses: actions/upload-pages-artifact@v3
with:
path: dist
- id: deployment
uses: actions/deploy-pages@v4

Every push to main publishes. The deployment URL shows up on the workflow run and under the repository's Environments.