Note · Being written · Updated 2026-11-11
Authentication: our own sign-in
How sign-in works (sessions, cookies, Google and GitHub login) and how this site moves from a hosted service to its own system on Better Auth and its own database.
Watch it happen
Press play. Tap a card.
Four short flows, one step at a time. Each card shows what that part knows, the dashes show what is on the move, and the mock browser shows what you would see.
Sign in without sharing a password
From pressing "Continue with Google" to being signed in.
Tap a card to learn what it is. Simulated. Nothing is sent anywhere. The steps follow how Better Auth documents these flows and what we saw on a dev machine (the provider address and the four tables). They have not been traced on the live site yet.
- OAuth
- The standard way to say "let Google tell this app who I am" without sharing a password.
- Session
- A record on our side that says "this person signed in, until this time".
- Cookie
- A small note the browser keeps and sends back with every request to the same site.
- Token
- A long random string. Having it is what proves a session, so it is never shown on a page.
- Callback
- The address on our app the provider sends you back to after you log in.
Why move off a hosted service
Today, sign-in for guide comments is handled by a hosted service. It works, but the sign-in screens, the user list and the sessions all live on someone else’s servers.
The goal is to run sign-in inside this app, with users stored in our own Postgres database, and to understand each part well enough to explain it here.
The parts of sign-in
- Identity
- Who is this? A Google or GitHub account, or an email address proven by a link.
- Session
- After sign-in, the browser holds a cookie. The server looks it up on each request to know who is asking.
- Storage
- A users table, a sessions table, and a table linking each user to the accounts they signed in with.
- Protection
- Rate limits on sign-in, cookies the page script cannot read, and checks that a request really came from our site.
The plan
- Library
- Better Auth, running inside this Next.js app and writing to our own Neon database. Chosen over writing the security-critical parts by hand.
- Methods
- Google and GitHub today. An emailed sign-in link is built too, but switched off for now.
- Order
- Add it beside the current sign-in first, move the comments over, then remove the hosted service.
What is done and what is not
- Done
- Better Auth runs inside this app on our own Neon database (four tables: user, session, account, verification). A sign-in page and a header button exist on this site.
- Checked
- On a dev machine: the sign-in endpoint answers, and Google and GitHub each return a login address for our app.
- Not checked yet
- A full sign-in with a real Google or GitHub account, the emailed magic link end to end, and anything on the live site.
- Still to do
- Move the guide comments over from the hosted service, share the session across subdomains, then remove the hosted service.