PetraPay is open source. You can run your own instance: a Next.js web app and a Node.js API with PostgreSQL. A common setup is the web app on Vercel and the API on Railway.
Requirements
- Node.js 20.19+ and pnpm
- PostgreSQL 15+
- An API key for the swap network (see the API's example env file)
Deploy the API
Create the service
On Railway, create a service from the repository and add a PostgreSQL database. The repository's
railway.jsonsets the build and start commands and a/healthcheck.Set environment variables
Copy the variables from
apps/api/.env.example. The important ones:Variable Purpose DATABASE_URL Your PostgreSQL connection string. APP_ORIGIN Your web app's URL, e.g. https://pay.example.com. Used for CORS and checkout URLs. COOKIE_SECURE true in production. APP_FEE_BPS Optional platform fee in basis points (0–400). Needs APP_FEE_RECIPIENT. WORKER_ENABLED Runs the background worker that tracks payments and delivers webhooks. Deploy
The start command applies database migrations, then starts the server. Attach a custom domain such as
api.example.com.
Deploy the web app
Import the project
On Vercel, import the repository and set the root directory to
apps/web. Itsvercel.jsoninstalls only what the web app needs.Point it at your API
Variable Purpose API_URL The API's URL. The web app proxies /api/* to it. NEXT_PUBLIC_API_ORIGIN The public API origin shown in these docs and the dashboard, e.g. https://api.example.com. NEXT_PUBLIC_SOLANA_RPC_URL A Solana RPC for the Pay with wallet button.
Run locally
pnpm install
cp apps/api/.env.example apps/api/.env # fill it in
cp apps/web/.env.example apps/web/.env.local
pnpm --filter @petrapay/api exec prisma migrate deploy
pnpm dev-PPETRAPAY_API_URL=https://api.example.com. See the POS app's README.