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.

Simon, Founder of Shipyard

By · Founder of Shipyard

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 appSupabase Auth
Where users liveYour own PostgresThe Supabase project
Database it works withPostgres on Railway, or SupabaseSupabase only
Extra variables on the hostNoneThree Supabase values
Settings outside your codeNoneSite 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.

VariableValueWhere it may go
NEXT_PUBLIC_SUPABASE_URLhttps://<project ref>.supabase.coBrowser and server
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEYStarts with sb_publishable_Browser and server. Row Level Security limits what it can read
SUPABASE_SECRET_KEYStarts 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

  1. Domain and DNS zone, then the repository, as for any stack.
  2. Railway project with the web service, and the worker if you asked for one. No Postgres service is added.
  3. Supabase project in your organisation. Wait until its database reports healthy.
  4. Read the pooled connection string and the two keys, then set the Site URL and the redirect list to the live domain.
  5. Custom domain on Railway, the Resend domain, Stripe in test mode.
  6. Variables to every Railway service, then the health check.
  7. 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

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 S101000000002000

The 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.

Sources

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 stack

Read next