Auth & email setup
Use this when you want the contact form, Supabase auth, and Resend newsletter contacts to work for real.
The kit can include:
- Contact form email delivery with Resend.
- Supabase auth: email + password, magic link, and Google / GitHub / Apple sign-in, plus password reset.
- A protected
/appzone (/login,/register,/forgot-passwordare the auth screens). - Automatic Resend Contact sync after a user signs in.
1. Create .env
Copy .env.example to .env.
Start the dev server:
pnpm devSet VITE_SITE_URL to the exact origin printed in the terminal:
VITE_SITE_URL=http://localhost:5173If Vite prints http://localhost:5174/ or another port, use that origin instead. Restart the dev server after changing .env.
2. Configure Supabase auth
- Create a Supabase project.
- In Supabase, open Project Settings -> API.
- Copy the project URL into
VITE_SUPABASE_URL. - Copy the anon/public key into
VITE_SUPABASE_ANON_KEY. - Open Authentication -> URL Configuration.
- Set Site URL to the exact
VITE_SITE_URL. - Add this redirect URL, using the same origin:
http://localhost:5173/auth/callbackIf your dev server uses another port, change the redirect URL to match.
After deploying, add your production callback too:
https://yourdomain.com/auth/callbackOpen Authentication -> Providers -> Email. This single provider powers both auth methods the
kit's /login and /register screens offer:
- Email + password — enabled by default. Leave "Confirm email" on (Supabase default) and new sign-ups receive a confirmation link before their first session.
- Magic link — make sure Email OTP is enabled.
Password reset (the /forgot-password screen) works out of the box once the Email provider is on;
the reset link returns to /auth/callback.
Useful docs:
3. Configure Google sign-in
- Open Authentication -> Providers -> Google in Supabase.
- Copy the callback URL shown there. It usually looks like
https://your-project-ref.supabase.co/auth/v1/callback. - In Google Auth Platform, create an OAuth client with application type Web application.
- Add your app origin under Authorized JavaScript origins, for example
http://localhost:5173and your production domain. - Add the Supabase callback URL under Authorized redirect URIs.
- Copy the Google Client ID and Client Secret back into Supabase's Google provider settings.
- Enable the Google provider.
GitHub and Apple
The /login and /register screens also have GitHub and Apple buttons. They follow the same
pattern as Google: open Authentication -> Providers -> GitHub (or Apple) in Supabase,
create an OAuth app on the provider side, point its callback at the Supabase callback URL, and
paste the client id/secret back into Supabase. Only the providers you enable will work; the rest
return an error on click.
Useful docs:
4. Configure Resend email delivery
The /contact page is wired to Resend. Add these values to .env:
RESEND_API_KEY=re_xxxxxxxxxxxxxxxxxxxxxxxxx
CONTACT_TO_EMAIL=you@yourdomain.com
CONTACT_FROM_EMAIL="Your site <contact@yourdomain.com>"In Resend:
- Create an API key.
- Verify the sending domain used by
CONTACT_FROM_EMAIL. - Make sure
CONTACT_FROM_EMAILuses an address from that verified domain. - Restart the dev server after changing
.env.
5. Configure Resend contacts for newsletters
To add every signed-in Supabase user to Resend Contacts, create a Segment in Resend and set:
RESEND_SEGMENT_ID=seg_xxxxxxxxxxxxxxxxxxxxxxxxxFor newsletter subscription preferences, create a Topic in Resend and set:
RESEND_TOPIC_ID=topic_xxxxxxxxxxxxxxxxxxxxxxxxxOnly set RESEND_TOPIC_ID if users should be opted into that Topic when they register. When RESEND_API_KEY and RESEND_SEGMENT_ID or RESEND_TOPIC_ID are present, the app adds the user's email to Resend after magic link or Google sign-in. Existing contacts are synced to the Segment/Topic so repeat sign-ins do not fail auth.
Useful docs:
6. Test the setup
- Restart the dev server after editing
.env. - Visit
/contactand submit a test message. - Visit
/login, sign in with a magic link or email + password, then open/app. - If Google / GitHub / Apple are enabled, test those buttons too.
- In Resend, confirm the signed-in email appears in Contacts and the configured Segment/Topic.
Before Supabase is configured,
/loginshows an "env missing" notice and/appredirects to/login— there is no demo session.
Production checklist
Before going live:
- Set
VITE_SITE_URLto your production origin. - Add
https://yourdomain.com/auth/callbackto Supabase redirect URLs. - Add your production origin to Google OAuth Authorized JavaScript origins.
- Keep the Supabase callback URL in Google OAuth Authorized redirect URIs.
- Use a verified production sender domain in Resend.