- Install Turso on your machine:
curl -sSfL https://get.tur.so/install.sh | bash
- Verify the installation:
turso --version
- Use the auth command to start the login process. The command launches your default browser and prompts you to log in with GitHub:
turso auth login
- Create a new Turso database:
turso db create magic-link
- Create an auth token to get access to your database using libSQL. Copy the auth token to Clipboard.
turso db tokens create magic-link
- Change the
.env
file to use the Turso database
cp .env.example .env # duplicate .env.example & name it .env
- Paste the generated auth token above in
.env
file next toTURSO_AUTH_TOKEN
:
TURSO_AUTH_TOKEN=[paste-the-generated-auth-token-without-brackets]
- Run this command to get the database URL:
turso db show magic-link --url
- Paste the generated url above in
.env
file next toTURSO_URL
:
TURSO_URL=libsql://[your-database]-[your-github].turso.io
pnpm install
pnpm start
pnpm db:push
pnpm db:generate
-
/api/signup
-> if email already exists, return 400 error. if not, then send magic link via email & redirect to/verify-email
page with further instructions -
/api/login
-> if email doesn't exist in the database, return 400 error. if not, then send magic link via email & redirect to/verify-email
page with further instructions -
/api/verify-email
-> if magic link is clicked inside email, then verify email on/api/verify-email
. finally, create lucia session & redirect to/dashboard
-
/api/logout
-> if logout button is clicked, then invalidate all sessions & redirect to/login
-
redirect from
/
,/login
,/signup
,/check-email
to/dashboard
if session exists. -
redirect from
/dashboard
to/login
if session doesn't exist.