
Deploy Play Games
Self Host custom html5,threejs game,admin dashbord added
PlayGames
Just deployed
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
/developerportal. - 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
- Railway Documentation
- Next.js Documentation
- Prisma Documentation
- PostgreSQL Documentation
- Three.js Documentation
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
| Setting | Value |
|---|---|
| Proxy Type | HTTP Proxy |
| Target Port | 3000 |
| Protocol | HTTP |
| Public Access | Railway 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
| Variable | Required | Description |
|---|---|---|
DATABASE_URL | Yes | PostgreSQL connection string used by Prisma |
JWT_SECRET | Yes | Secret used to sign and validate JWT sessions |
NEXT_PUBLIC_APP_URL | Yes | Public URL of the deployed application |
ADMIN_EMAIL | Yes | Email for the seeded Super Admin |
ADMIN_PASSWORD | Yes | Password for the seeded Super Admin |
ADMIN_NAME | Yes | Display 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.
- Add a PostgreSQL service to the Railway project.
- Configure
DATABASE_URLon the PlayGames service. - Deploy the application.
- Initialize the Prisma schema.
- 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:
| Role | Access |
|---|---|
PLAYER | Gaming, favorites, ratings, and multi-screen mode |
DEVELOPER | Game submission and management |
SUPER_ADMIN | Platform 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:
| Role | Password | |
|---|---|---|
| Super Admin | admin@play123.com | admin123 |
| Developer | developer@play123.com | dev123 |
| Player | Created through signup | User-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:
- Provision PostgreSQL.
- Configure all required Railway variables.
- Use a strong production
JWT_SECRET. - Replace demo administrator credentials.
- Deploy the Docker-based application.
- Run
pnpm db:push. - Run
pnpm db:seedfor a new installation. - Generate the Railway HTTPS domain.
- Set
NEXT_PUBLIC_APP_URLto the public URL. - 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
PlayGames
bilalnawaz072/PlayGames