Railway with Supabase as the database and Supabase Auth for sign-in
Running the app on Railway while Supabase holds the data and the sign-in: the keys, the redirect settings, the email limit, and what each choice costs.
This is the stack for a product that needs a server that stays up, perhaps with a background worker, and whose owner would rather not build sign-in. Railway runs the processes. Supabase is the Postgres database and also answers the question of who is signed in.
Splitting things this way adds a second account and a handful of settings that live at Supabase and not in your code. Those settings are what this page is about, because they are the part that is invisible until a customer does not get a confirmation email.
Built-in sign-in or Supabase Auth
Shipyard offers two ways to sign people in. The built-in one is email and password with sessions stored in your own Postgres. It works with either database and adds no account. Supabase Auth hands the whole job to Supabase, and it needs Supabase as the database: the stack picker moves the database for you if you choose it.
Pick Supabase Auth when you want confirmation and reset emails, and later social sign-in, without writing them. Pick the built-in one when you want the fewest moving parts and every user row in a table you control.
| Built into the app | Supabase Auth | |
|---|---|---|
| Where users live | Your own Postgres | The Supabase project |
| Database it works with | Postgres on Railway, or Supabase | Supabase only |
| Extra variables on the host | None | Three Supabase values |
| Settings outside your code | None | Site URL, redirect list, email sending |
What changes on Railway when the database moves out
With Postgres on Railway, the app's DATABASE_URL is a reference that Railway resolves and nobody else reads. With Supabase the database is outside the project, so DATABASE_URL becomes a real secret: a full connection string, password included, written to the web service and to the worker if there is one.
That password is not one you typed. Shipyard generates it on your computer when it creates the Supabase project and keeps it in your keychain, so a launch that is interrupted and resumed uses the same one. Supabase does not show a database password again after creation, which is why it has to be kept somewhere.
Railway runs long-lived processes, and for those Supabase recommends a direct connection when the network has IPv6 or you bought the IPv4 add-on, and session mode on the shared pooler otherwise. Shipyard writes the pooled string on every host, because it works over IPv4 without an add-on. If your app holds many connections open, read the port in the value and compare it with Supabase's table before you tune a pool size.
The three Supabase values
Supabase now issues two kinds of key, and the older pair is on its way out: its documentation says the anon and service_role keys are being deprecated by the end of 2026. Shipyard asks the project for the new kind, creates them if the project has none, and falls back to the old ones only when it must.
The names matter, because many tutorials still use the old ones. If your code reads NEXT_PUBLIC_SUPABASE_ANON_KEY, it will find nothing under that name. Shipyard compares the names in your repository's .env.example with what it is about to write and tells you in the plan, before anything is created.
| Variable | Value | Where it may go |
|---|---|---|
NEXT_PUBLIC_SUPABASE_URL | https://<project ref>.supabase.co | Browser and server |
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY | Starts with sb_publishable_ | Browser and server. Row Level Security limits what it can read |
SUPABASE_SECRET_KEY | Starts with sb_secret_ | Server only. It bypasses Row Level Security |
Where sign-in links point
Two settings at Supabase decide where a person lands after clicking a confirmation or reset link. The Site URL is the default destination, and a new project has it set to http://localhost:3000. Leave that in place and every confirmation email sends your customers to their own computer. The redirect list holds the other addresses your code may ask for.
Shipyard sets both when it creates the project: the Site URL to https://example.com and the redirect list to https://example.com/**. In Supabase's pattern language ** matches any sequence of characters, so every path on your domain is allowed and nothing on any other domain is. Supabase recommends exact paths in production. Once you know which pages your sign-in flow really returns to, replace the wildcard with those.
Local development is not on that list. Add http://localhost:3000/** yourself while you build, and take it out again before launch.
The limit on sign-in emails
This one fails quietly. A new Supabase project sends its sign-in emails through Supabase's built-in mail service, and that service is for trying things out. Supabase documents three limits: it only delivers to addresses that belong to your own team, it is capped at two messages an hour at the time of writing, and it is described as not meant for production use. A stranger who signs up gets nothing, and the API answers that the address is not authorised.
The fix is to give Supabase an SMTP server of your own: host, port, user name, password and a From address. Resend is one of the services Supabase lists as working, and this stack already has a verified Resend domain, so the pieces are there. Shipyard does not do this step. Its Resend key for your app is created for the app, and it leaves the SMTP settings of your Supabase project alone. Do it by hand in the Supabase dashboard before you invite anyone.
After you switch, Supabase starts you at 30 messages an hour and lets you raise that on its rate limits page. Raise it before a launch day, not during one.
The order for this stack
- Domain and DNS zone, then the repository, as for any stack.
- Railway project with the
webservice, and the worker if you asked for one. No Postgres service is added. - Supabase project in your organisation. Wait until its database reports healthy.
- Read the pooled connection string and the two keys, then set the Site URL and the redirect list to the live domain.
- Custom domain on Railway, the Resend domain, Stripe in test mode.
- Variables to every Railway service, then the health check.
- By hand: custom SMTP in Supabase, and a real sign-up with an address outside your team.
What goes wrong, and what it looks like
- Shipyard cannot find the organisation. The token works, but the slug you gave is not one it can see. The error lists the slugs it can.
- Sign-up works for you and for nobody else. That is the built-in mail service delivering only to team addresses. Set up custom SMTP.
- A confirmation link opens
localhost. The Site URL was changed back, or a second project was created by hand without it. - A request with the secret key fails in the browser with 401. Supabase rejects secret keys there on purpose. Move the call to the server.
- The worker cannot reach the database after a week of no traffic. Free Supabase projects are paused after a week with too little database activity. Supabase says a few real requests a day are usually enough to prevent it, without promising so.
Start from this stack
This code keeps Railway for hosting, moves the database to Supabase and switches sign-in to Supabase Auth. Removing the product later deletes the Supabase project along with the Railway one; the DNS zone is always kept.
shipyard stack use S101000000002000The setup article for each provider
Each provider in this guide has one article with its full steps. They are all listed on the integrations page.
- Railway: A project with a web service and Postgres, linked together, with every variable and your domain.
- Supabase: A project in your region, with its connection string and keys written into your host.
- Resend: The sending domain, its DKIM, SPF and DMARC records, verification and a sending-only key.
- Cloudflare DNS: The zone, the nameservers and every record your host, email and Google need.
Sources
- Supabase: redirect URLssupabase.com
- Supabase: send emails with custom SMTPsupabase.com
- Supabase: API keyssupabase.com
- Supabase: connect to your databasesupabase.com
- Supabase: do projects pause when inactive?supabase.com
- Railway: PostgreSQLdocs.railway.com
Have this set up for you
Shipyard creates everything on this page on your own accounts, from your coding agent. Your keys stay in the keychain on your computer, and anything that costs money waits for your yes.
Pick your stackRead next
- Supabase or plain Postgres on your host
- Supabase for a new product
- Sign in with Google
- SPF, DKIM and DMARC explained
- Next.js on Railway with Postgres, Resend and Stripe: how the pieces connect
- Next.js on Vercel with Supabase: connection strings, DNS and variables
- Cloudflare Registrar or Namecheap for a new product's domain