BetterRewardsDocs
Open app
Browse guides

Deploy on Vercel

No server to look after: Vercel runs the app from your GitHub repository, with a Neon Postgres database. One click, or step by step.

6 min read · For companies

Vercel builds and runs betterrewards from a copy of the repository on your GitHub account and redeploys whenever you push. The database is Neon, a hosted Postgres you can create from inside Vercel. Background jobs run right after the requests that create them and on a Vercel schedule. Nothing needs to run on your computer.

You needNotes
A Vercel accountHobby is free but for personal, non-commercial use only. Running a company's partner program is commercial, so use Pro for that; Hobby is fine for trying it out.
A GitHub accountTo hold your copy of the repository.
A Neon databaseCreated for you by Vercel. The free tier is enough to start.
A way to send emailA Resend account (resend.com), or an SMTP provider.
A Stripe accountConnected after the first sign-in, from the admin.

One click

The quickest way, about 10 minutes. The button copies the repository to your GitHub account, creates the Vercel project with a Neon database, and asks for five settings:

Deploy with Vercel

SettingValue
AUTH_SECRETA long random value: run openssl rand -base64 32. Keep a copy: changing it signs everyone out and makes saved Stripe keys and payout details unreadable.
CRON_SECRETAnother random value: openssl rand -hex 32. Lets the schedule run background jobs.
OWNER_EMAILYour email address. Your first sign-in with it makes you the owner.
EMAIL_FROMThe sender of sign-in emails. The suggested one is Resend's test sender (see below).
RESEND_API_KEYAn API key from resend.com (free to start).

Resend's test sender, onboarding@resend.dev, only delivers to the address you signed up to Resend with. Use that address as OWNER_EMAIL to sign in right away. Before inviting partners, verify your own domain at Resend, change EMAIL_FROM under Settings → Environment Variables and redeploy.

When the deployment is ready, open it and sign in with OWNER_EMAIL. The first visit creates the database tables, so it takes a few seconds. The setup wizard then walks you through your company, Stripe, a first program and the tracking snippet; the Getting started guide for product owners explains each step.

The steps below do the same by hand, for when you want to see each piece or use SMTP.

Hobby or Pro

The setup is identical. What changes is how often scheduled jobs run: on Hobby at most every 15 minutes, on Pro every minute if you set BR_TICK_CRON to * * * * *. Sign-in, click tracking, Stripe payments and the emails they trigger never wait for the schedule. What can run up to about 30 minutes late on Hobby: approving commissions after their hold period, preparing the payout batch on payout day, retries of failed outbound webhooks, and turning off the Stripe codes of a program that just ended.

1. Import the repository

  1. On GitHub, fork github.com/betterrewards/betterrewards to your account.
  2. In Vercel, choose Add New → Project and import your fork.
  3. Leave Root Directory, the framework preset and the build settings as they are: the repository configures them.
  4. Click Deploy. This first deployment builds but cannot work yet (no database, no settings). That is expected.

Note the address Vercel gives the project, for example https://my-rewards.vercel.app. You can add your own domain later.

2. Add the database

In the project, open Storage → Create Database → Neon, pick a region close to your users and connect it to the project. Vercel adds DATABASE_URL to the project's environment variables. The app creates its tables itself on the first visit after each deploy.

3. Add the settings

Settings → Environment Variables, for the Production environment. Generate the two secrets in a terminal with the commands shown.

NameValue
AUTH_SECRETopenssl rand -base64 32. Keep a copy: changing it signs everyone out and makes saved Stripe keys and payout details unreadable.
CRON_SECRETopenssl rand -hex 32. Lets Vercel's schedule start background jobs. Without it, scheduled jobs never run.
OWNER_EMAILYour email address. Your first sign-in with it makes you the owner.
EMAIL_FROMRewards <rewards@example.com>, on a domain your email provider allows
RESEND_API_KEYFrom resend.com. Or, for SMTP: SMTP_HOST, SMTP_PORT, SMTP_USER and SMTP_PASSWORD.
BR_TICK_CRONOptional, Pro only: * * * * * for jobs every minute

APP_URL, the dashboard address, is filled in for you: the project's vercel.app address, or your own domain once you add one. Add CRON_SECRET to Production only, so preview deployments never run the production jobs.

4. Redeploy and sign in

Settings changes apply to new deployments only. In Deployments, open the latest one and choose Redeploy. Then open the project address, enter OWNER_EMAIL and click the link you receive. The first visit creates the database tables, so it takes a few seconds. The setup wizard then walks you through your company, Stripe, a first program and the tracking snippet; the Getting started guide for product owners explains each step.

5. Your own domain

  1. Settings → Domains: add rewards.example.com and create the DNS record Vercel shows.
  2. Redeploy. The dashboard address follows the new domain: no APP_URL to set, no code to change.
  3. For short links, add go.example.com as a domain too, set TRACKING_DOMAIN=go.example.com and redeploy.
  4. Add the domain before connecting Stripe if you can. If Stripe was already connected, save the key again in Integrations → Stripe: the webhook moves to the new address and keeps its signing secret.

Check that it works

  • The sign-in email arrives within a minute, in the inbox.
  • Background jobs: run the schedule once by hand with npx vercel link, then npx vercel schedules invoke betterrewards-jobs. The function logs show [jobs] tick when there was work.
  • Integrations → Tracking & links: the tracking check turns green once the snippet is on your site.

Update to a new version

On GitHub, open your copy of the repository and click Sync fork (with the button, your copy is a new repository: pull the changes from github.com/betterrewards/betterrewards into it). Vercel deploys the new version, and its first request applies any database changes. Read the changelog before updating.

Troubleshooting

What you seeWhat to do
The build fails right awayRoot Directory must be the repository root (Settings → Build and Deployment).
The page shows an error (500)Open the deployment's Logs. An invalid or missing setting is named there; so is a database that cannot be reached.
Settings changed but nothing is differentRedeploy: settings are read when a deployment is created.
No sign-in emailThe function logs show the email provider's error. With Resend's test sender, OWNER_EMAIL must be your Resend account address. Otherwise check that EMAIL_FROM is an allowed sender.
You signed in but see the partner portal, not the adminYou signed in with another address than OWNER_EMAIL, or the instance already has an owner. Check OWNER_EMAIL and redeploy.
Commissions never get approved, payout batches never appearScheduled jobs are not running: CRON_SECRET is missing in Production, or the schedule was not created. Redeploy after setting it.