Authentication
Authentication (Email + Social) - quick setup
Setting up auth is pretty simple here — it’s already configured in main.wasp
.
// main.wasp
auth: {
userEntity: User,
methods: {
email: {},
google: {},
github: {},
discord: {}
},
onAuthFailedRedirectTo: "/",
},
Defining auth in main.wasp
lets Wasp generate the auth flow for you:
- DB entities for credentials/sessions/social logins
- Auto-generated AuthUI client components (see
src/auth
) - Hooks for accessing the current user
Email-Verified Auth (default)
Email auth is the default in LaunchPike.
Because verification/reset requires sending emails, you must have an email sender configured under app.emailSender
in main.wasp
.
Dev: Dummy Email Provider (already set)
To speed up onboarding, LaunchPike ships with a Dummy email sender: it doesn’t send real emails — it logs verification links/tokens to the server console. Check the link from the logs to verify the user and finish signup.
// main.wasp
emailSender: {
provider: Dummy, // logs all email verification links/tokens to the terminal
defaultFrom: {
name: "LaunchPike App",
email: "[email protected]"
},
},
You cannot use Dummy in production. The app will not build until you switch to a production-ready provider (e.g. SendGrid).
Prod: Move to SendGrid (required for email auth in prod)
- Configure
app.emailSender
inmain.wasp
following this guide. - Add your
SENDGRID_API_KEY
to.env.server
. - Ensure the From email in
fromField
matches the sender address configured in your SendGrid account.
Final main.wasp
(structure as shown below):
// main.wasp
auth: {
methods: {
email: {
fromField: {
name: "LaunchPike App",
// When using SendGrid, you must use the same email address that you configured
email: "[email protected]"
},
//...
},
}
},
//...
emailSender: {
provider: Dummy,
provider: SendGrid,
defaultFrom: {
name: "LaunchPike App",
// When using SendGrid, you must use the same email address that you configured
email: "[email protected]"
},
},
Google, GitHub & Discord (Social Auth)
Google/GitHub flows are pre-built. To enable:
-
Uncomment the providers you want in
main.wasp
(methods.google
,methods.github
,methods.discord
). -
Create the corresponding OAuth apps and add the keys to
.env.server
.- Google: follow Wasp’s Google Auth docs
- GitHub: follow Wasp’s GitHub Auth docs
- Discord: follow Wasp’s Discord Auth docs
Once keys are set, Wasp wires the client/server pieces and updates the AuthUI for you.