Railway

Deploy React | Vite SPA Starter That Actually Has a Start Command

React 19 on Vite, served as static files with SPA routing and health check

Deploy React | Vite SPA Starter That Actually Has a Start Command

Deploy and Host a React App on Railway

A React 19 single-page app, built with Vite and served as static files.

About Hosting React

The Create React App template on Railway still builds with react-scripts 5.0.1 and React 18, from a repository last touched in July 2024. Two things are wrong with it, and the second is the one that actually stops deployments.

Create React App is retired. The React team deprecated it in February 2025 and now points people at Vite for this exact kind of app. react-scripts carries a large tree of unmaintained transitive dependencies, and Railway refuses to build when the committed lockfile contains a HIGH advisory.

There is nothing to run after the build. That project defines only dev and build scripts. No start. So even a build that somehow succeeds leaves the platform with nothing to launch.

This template builds with Vite and ships a start command that serves the built output.

Common Use Cases

  • A React front end deployed on its own, talking to an API you host separately
  • A dashboard or marketing page where a full server framework would be overkill
  • A starting point for a client-side app that will grow routing and state

Dependencies for React Hosting

  • Nothing. It is one service with no database and no volume.

Deployment Dependencies

Implementation Details

The repository includes a 60-line server.js rather than a static-server dependency. A built React app needs exactly three things - correct content types, a fallback to index.html so client-side routes survive a refresh, and a port it can be told about - and that is short enough to read in one sitting. Keeping it dependency-free also means nothing can quietly pull an advisory into the lockfile and block a future build.

Two details in it worth keeping if you rewrite it:

  • Assets under /assets are fingerprinted by Vite, so they are served immutable. index.html is served no-cache - otherwise a deploy leaves browsers pinned to the previous build, loading asset URLs that no longer exist.
  • Request paths are normalised before being joined to the build directory, so .. cannot escape it.
VariableWhy
PORTThe port the server binds; Railway routes the public domain to it

Build and deploy settings, including the health check on /healthz, live in railway.json in the repository, so they travel with your code when you fork it.

Why Deploy React on Railway?

Push, and the build and the static server are both handled. No bucket to configure, no CDN to point at it, and a health check that tells you honestly whether the app came up.


Template Content

More templates in this category

View Template
open-excalidraw
Self-hostable collaborative drawing built on Excalidraw

Prateek Mohanty
1
View Template
caring-vibrancy
Deploy and Host caring-vibrancy with Railway

5
View Template
Flask WebSocket Chat
Single file, realtime multi-user websocket chat using flask-socketio

Clement Ochieng
3