- 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
.envfile to use the Turso database
cp .env.example .env # duplicate .env.example & name it .env- Paste the generated auth token above in
.envfile 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
.envfile next toTURSO_URL:
TURSO_URL=libsql://[your-database]-[your-github].turso.iopnpm installpnpm startpnpm db:pushpnpm db:generate-
/api/signup-> if email already exists, return 400 error. if not, then send magic link via email & redirect to/verify-emailpage 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-emailpage 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-emailto/dashboardif session exists. -
redirect from
/dashboardto/loginif session doesn't exist.