Skip to main content
Version: Next

Function: waspAuth()

waspAuth(config): WaspAuthProviderConfig

Selects Wasp's own authentication as the app's auth provider and configures it: enabled methods, auth hooks, and the post-login redirect.

Everything in here only makes sense when Wasp itself runs the signup and login flows, which is why it lives inside waspAuth() rather than on app.auth -- under an external provider none of it would apply, and the types make that state impossible to write.

Parameters

config

WaspAuthConfig

Wasp auth configuration; methods must enable at least one.

Returns

WaspAuthProviderConfig

Example

import { app, waspAuth } from '@wasp.sh/spec'

auth: {
userEntity: "User",
onAuthFailedRedirectTo: "/login",
provider: waspAuth({
methods: { usernameAndPassword: {} },
onAuthSucceededRedirectTo: "/",
}),
}