Railway

Deploy Play Games

Self Host custom html5,threejs game,admin dashbord added

Deploy Play Games

Just deployed

/var/lib/postgresql/data

Deploy and Host PlayGames on Railway

PlayGames is a full-stack browser gaming platform built with Next.js 14, TypeScript, Three.js, Prisma ORM, and Tailwind CSS. It provides native 3D WebGL games, multi-screen gaming, an AI Gaming Buddy, dynamic themes, player authentication, developer game submissions, game moderation, analytics, and a Super Admin dashboard.

About Hosting PlayGames

Hosting PlayGames on Railway requires a Next.js application service and PostgreSQL database. The included multi-stage Dockerfile packages the application for production, while Railway manages deployment, infrastructure, environment variables, public networking, and HTTPS. PostgreSQL stores persistent application data including users, games, categories, ratings, favorites, moderation data, and site configuration through Prisma ORM. The application listens on port 3000 and can be exposed through a Railway-generated HTTPS domain. Configure the required database and authentication variables before the first production deployment, then initialize the Prisma schema and seed the default application data. No persistent Railway Volume is documented as required because application data is stored in PostgreSQL.

Common Use Cases

  • 3D Browser Gaming Platform — Host native Three.js/WebGL games alongside HTML5/IFrame games.
  • Developer Game Portal — Allow developers to submit, edit, and monitor games through the /developer portal.
  • Gaming Administration Platform — Manage users, games, categories, moderation, site configuration, and analytics through /admin.

Dependencies for PlayGames Hosting

  • PostgreSQL — Required for persistent application data and Prisma ORM.
  • Docker — The repository includes a production multi-stage Dockerfile.
  • Prisma ORM — Provides PostgreSQL database access and schema management.
  • JWT Secret — Required for secure authentication sessions.
  • Railway HTTP Networking — Required to expose the application publicly.

Deployment Dependencies

Implementation Details

Docker

PlayGames includes a multi-stage production Dockerfile. Railway automatically detects and builds the Dockerfile, so no external Docker registry is required.

The production application uses the project's documented build and start scripts:

pnpm build
pnpm start
Public Networking
SettingValue
Proxy TypeHTTP Proxy
Target Port3000
ProtocolHTTP
Public AccessRailway HTTPS Domain

After deployment, generate a domain from Railway → Service → Settings → Networking → Generate Domain.

Set NEXT_PUBLIC_APP_URL to the resulting public URL.

Environment Variables
VariableRequiredDescription
DATABASE_URLYesPostgreSQL connection string used by Prisma
JWT_SECRETYesSecret used to sign and validate JWT sessions
NEXT_PUBLIC_APP_URLYesPublic URL of the deployed application
ADMIN_EMAILYesEmail for the seeded Super Admin
ADMIN_PASSWORDYesPassword for the seeded Super Admin
ADMIN_NAMEYesDisplay name for the seeded Super Admin

Raw Editor example:

DATABASE_URL=postgresql://...
JWT_SECRET=replace-with-a-secure-random-secret
NEXT_PUBLIC_APP_URL=https://your-domain
ADMIN_EMAIL=admin@play123.com
ADMIN_PASSWORD=replace-with-a-secure-password
ADMIN_NAME=Super Admin

Use the PostgreSQL connection string provided by the Railway PostgreSQL service. Generate a strong, unique JWT_SECRET and production administrator password. Do not commit production secrets to source control.

Database

PlayGames requires PostgreSQL and uses Prisma v5.

  1. Add a PostgreSQL service to the Railway project.
  2. Configure DATABASE_URL on the PlayGames service.
  3. Deploy the application.
  4. Initialize the Prisma schema.
  5. Seed the documented default data.

Schema initialization:

pnpm db:push

Equivalent command:

npx prisma db push

Seed the initial categories, games, administrator, and developer data:

pnpm db:seed

Only run the seed process when initializing the documented default data or after reviewing the seed implementation for an existing production database.

Persistent Storage

No Railway Volume is documented as required.

PostgreSQL stores persistent application data, while static assets and game thumbnails are included in the application's public/ directory.

Build & Start

No custom Railway build or start commands are required when deploying with the included Dockerfile.

The documented production commands are:

pnpm build
pnpm start

The application runs on port 3000.

Authentication

PlayGames implements custom authentication using JWT session cookies, jsonwebtoken, and bcryptjs.

Supported roles include:

RoleAccess
PLAYERGaming, favorites, ratings, and multi-screen mode
DEVELOPERGame submission and management
SUPER_ADMINPlatform administration and moderation

Authentication endpoints include:

POST /api/auth/register
POST /api/auth/login
POST /api/auth/logout
GET  /api/auth/me
Seeded Accounts

The documented seed creates:

RoleEmailPassword
Super Adminadmin@play123.comadmin123
Developerdeveloper@play123.comdev123
PlayerCreated through signupUser-defined

The credentials above are demo credentials. Replace them with secure production values before using the deployment publicly.

Application Routes

Key application routes include:

/                    Homepage
/play/[slug]         Game player
/multiscreen         Multi-screen gaming
/developer           Developer portal
/admin               Super Admin dashboard
Platform Features

PlayGames includes four built-in Three.js games:

  • Wave Dash — Synthwave 3D runner.
  • Cyber Drift — Cyberpunk tunnel drifting game.
  • Cube Stack — 3D precision stacking game.
  • Tunnel Runner — High-speed 360-degree tunnel runner.

The /multiscreen hub supports up to four games concurrently with documented 2x1, 2x2, and focus layouts.

The developer portal supports HTML5/IFrame games and Three.js games with moderation states including PENDING, APPROVED, and REJECTED.

The Super Admin dashboard provides site configuration, game moderation, category management, user role management, featured game controls, and platform analytics.

API

Documented game and platform endpoints include:

GET  /api/games
POST /api/games
GET  /api/games/[slug]
POST /api/games/[slug]/rate
POST /api/games/[slug]/favorite

GET  /api/categories
GET  /api/site-config
PUT  /api/site-config

GET   /api/admin/games
PATCH /api/admin/games/[id]

Administrative endpoints require the appropriate authenticated role.

Production Checklist

Before going live:

  1. Provision PostgreSQL.
  2. Configure all required Railway variables.
  3. Use a strong production JWT_SECRET.
  4. Replace demo administrator credentials.
  5. Deploy the Docker-based application.
  6. Run pnpm db:push.
  7. Run pnpm db:seed for a new installation.
  8. Generate the Railway HTTPS domain.
  9. Set NEXT_PUBLIC_APP_URL to the public URL.
  10. Verify authentication, games, database persistence, developer access, and /admin.

Why Deploy PlayGames on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying PlayGames on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


Template Content

More templates in this category

View Template
Rocky Linux
[Jul'26] Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀

codestorm
37
View Template
Foundry Virtual Tabletop
A Self-Hosted & Modern Roleplaying Platform

Lucas
71
View Template
Letta Code Remote
Run a Letta Code agent 24/7. No inbound ports, just deploy.

Letta
51