AUTHENTICATION / LESSON 01
What Is Authentication?
How apps know who you are, why login is hard to build, and how to choose an auth tool

Loading the lesson…
Loading activities…
AUTHENTICATION / LESSON 01
How apps know who you are, why login is hard to build, and how to choose an auth tool

Loading the lesson…
Loading activities…
The second your app has users, it needs to know who is who. That job is called authentication. This lesson walks through what it covers, where it lives in your app, and the two VERY different kinds of tools you can use for it.
Authentication answers one question... who is making this request?
When you log in to your email, you prove you're you, usually with a password. From that point on, the email service trusts that the requests coming from your browser are yours, right up until you log out.
Login looks like one lil form, but there's a LOT going on underneath it.
Every one of these has ways to go wrong, and a mistake here can expose your users' accounts. That's why most developers don't build auth from scratch.
I've seen the messy side of this firsthand. A WooCommerce site I was looking after got hit with a spam attack, and part of cleaning it up was locking things down so people couldn't create accounts without being signed in. Account stuff gets abused the moment you leave a door open.
Here's the basic flow, and you'll see it in every auth tool out there.
They type in an email and password, or click "Sign in with Google."
It compares the password hash, or asks Google to confirm who they are.
The auth system creates a session and hands the browser a small token, usually stored in a cookie (the computer kind, sadly).
Every time the browser asks your app for a page or some data, that token tags along with it.
Your code asks the auth system "who does this token belong to?" and then decides what to show.
Short answer? Pretty much everywhere. Your sign in pages use it. Your backend checks it before handing back private data. Your database usually has a users table, or links its records to a user ID from the auth tool. Even payments and emails need to know which user they belong to.
That's why it pays to pick your auth tool EARLY. Switching later means moving every single user account... and nobody wants that weekend.
This module covers one of each, and the difference matters.
| Hosted Service | Library You Run | |
|---|---|---|
| What it is | A company runs login for you on its servers | Code you install inside your own app |
| Where users live | On the service's servers | In your own database |
| Setup | Usually faster, with ready-made sign in pages | More steps, more control |
| Settings | Mostly in a web dashboard | Mostly in your code |
| Cost | Usually free to start, then priced by usage | The library can be free, you pay for your own hosting and database |
Clerk is a hosted service. Better Auth is a library you run yourself. (You can probably guess which way I lean, since I'm the own-your-tools guy, but you're learning both here so you can make that call yourself.)
When you're comparing auth tools, run through these questions.
| Tool | Kind | Chapter Covers |
|---|---|---|
| Clerk | Hosted service | How it works, adding it to your app, features and pricing |
| Better Auth | Library | What it is, installing it, using it in a Next.js app |
First up is the Clerk chapter, where you'll get to watch a hosted service handle sign up and log in for you...