Resources

Self-hosting

Run your own PetraPay instance.

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

  1. Create the service

    On Railway, create a service from the repository and add a PostgreSQL database. The repository's railway.json sets the build and start commands and a /health check.

  2. Set environment variables

    Copy the variables from apps/api/.env.example. The important ones:

    VariablePurpose
    DATABASE_URLYour PostgreSQL connection string.
    APP_ORIGINYour web app's URL, e.g. https://pay.example.com. Used for CORS and checkout URLs.
    COOKIE_SECUREtrue in production.
    APP_FEE_BPSOptional platform fee in basis points (0–400). Needs APP_FEE_RECIPIENT.
    WORKER_ENABLEDRuns the background worker that tracks payments and delivers webhooks.
  3. Deploy

    The start command applies database migrations, then starts the server. Attach a custom domain such as api.example.com.

Deploy the web app

  1. Import the project

    On Vercel, import the repository and set the root directory to apps/web. Its vercel.json installs only what the web app needs.

  2. Point it at your API

    VariablePurpose
    API_URLThe API's URL. The web app proxies /api/* to it.
    NEXT_PUBLIC_API_ORIGINThe public API origin shown in these docs and the dashboard, e.g. https://api.example.com.
    NEXT_PUBLIC_SOLANA_RPC_URLA 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
Point the POS app at your instance by building it with -PPETRAPAY_API_URL=https://api.example.com. See the POS app's README.