| 1 | # Railway Website: Next.js |
| 2 | |
| 3 | Deploys a [Next.js](https://nextjs.org) site to Railway with |
| 4 | `Railway.Website.Nextjs` — no adapter setup in the project config. |
| 5 | |
| 6 | Alchemy generates a Dockerfile and uploads the build context; Railway builds the image. The Service listens on port 3000. |
| 7 | |
| 8 | |
| 9 | - `app/page.jsx` is server-rendered on the Railway Service and reads `GREETING` from `process.env`. |
| 10 | - `app/api/hello/route.ts` is an App Router API route. |
| 11 | - This is `next build` plus a long-running Node process — not OpenNext. |
| 12 | |
| 13 | ```ts |
| 14 | const site = yield* Railway.Website.Nextjs("Nextjs", { |
| 15 | env: { GREETING: "Hello from Next.js on Railway!" }, |
| 16 | }); |
| 17 | ``` |
| 18 | |
| 19 | The integration package must be installed in the project (it is loaded |
| 20 | dynamically at deploy time): |
| 21 | |
| 22 | ```sh |
| 23 | bun add -d @alchemy.run/frontend-frameworks |
| 24 | ``` |
| 25 | |
| 26 | ## Deploy |
| 27 | |
| 28 | ```sh |
| 29 | bun run deploy |
| 30 | ``` |
| 31 | |
| 32 | Unchanged sources skip the build entirely on subsequent deploys — the |
| 33 | input files are content-hashed (scoped by `memo.include`). |
| 34 | |
| 35 | ## Dev |
| 36 | |
| 37 | ```sh |
| 38 | bun run dev |
| 39 | ``` |
| 40 | |
| 41 | `alchemy dev` runs the framework's own dev server (HMR included) and |
| 42 | no cloud resources are created. |
| 43 | |
| 44 | ## Destroy |
| 45 | |
| 46 | ```sh |
| 47 | bun run destroy |
| 48 | ``` |