Skip to main content
Version: Next

@wasp/spec

The @wasp/spec package has everything you need to write your app's Wasp Spec: the main.wasp.ts file where you define your app's pages, routes, queries, actions, auth, and more.

main.wasp.ts
import { app } from "@wasp/spec";

export default app({
name: "todoApp",
wasp: { version: "^0.26" },
title: "ToDo App",
spec: [],
});

Getting the package​

In a Wasp app​

You don't need to install anything. Wasp apps come with @wasp/spec already listed in their package.json, and the Wasp CLI manages it for you.

In a library​

If you are publishing a helper or library for the Wasp Spec, add @wasp/spec to both the devDependencies and the peerDependencies of your package.json. That way, you have a local copy during development, and your library uses the version installed in your users' Wasp projects:

package.json
{
"peerDependencies": {
"@wasp/spec": "^0.26"
},
"devDependencies": {
"@wasp/spec": "^0.26"
}
}

Wasp Spec​

App​

Root shape of a Wasp app specification.

Pass an App to the app constructor and export default the result from main.wasp.ts.

Example​

import { app } from "@wasp/spec"

export default app({
name: "todoApp",
wasp: { version: "^0.24.0" },
title: "ToDo App",
head: ["<link rel='icon' href='/favicon.ico' />"],
spec: [],
});

Properties​

auth?​

optional auth?: Auth

Configuration for authentication. Enables auth when set.

client?​

optional client?: Client

Configuration for the client part of the resulting Wasp app.

db?​

optional db?: Db

Configuration for the app's database.

deployment?​

optional deployment?: Deployment

Configuration for how the app will be deployed.

emailSender?​

optional emailSender?: EmailSender

Configuration for the app's email sender.

optional head?: string[]

Extra tags injected into the HTML <head>.

Each entry is rendered inside a React component, so the strings must be valid JSX: self-closing tags must end with /> (e.g. <meta ... />), and attributes must be camelCased (e.g. httpEquiv instead of http-equiv).

Due to a React bug, avoid defer on <script> tags because it can cause hydration warnings. Use async instead.

name​

name: string

Internal app name.

Must not contain spaces.

server?​

optional server?: Server

Configuration for the server part of the resulting Wasp app.

spec​

spec: Spec

The specification (Spec) of the app.

Build entries with the dedicated constructors (page, route, query, action, api, apiNamespace, job, crud).

title​

title: string

App title.

Used as the browser tab title.

wasp​

wasp: Wasp

Wasp metadata.

This will get checked against the Wasp CLI.

webSocket?​

optional webSocket?: WebSocket

Configuration for the app's WebSocket support.


AppConfig​

AppConfig = Omit<App, "kind">

The configuration object accepted by the app constructor.


app()​

app(config): App

Creates a Wasp App.

Call app() exactly once in your main.wasp.ts and export the result as the file's default export. The Wasp compiler reads this default export to generate your app.

See the Wasp Spec docs for the full shape of the configuration.

Parameters​

config​

The app configuration.

auth?​

Auth

Configuration for authentication. Enables auth when set.

client?​

Client

Configuration for the client part of the resulting Wasp app.

db?​

Db

Configuration for the app's database.

deployment?​

Deployment

Configuration for how the app will be deployed.

emailSender?​

EmailSender

Configuration for the app's email sender.

string[]

Extra tags injected into the HTML <head>.

Each entry is rendered inside a React component, so the strings must be valid JSX: self-closing tags must end with /> (e.g. <meta ... />), and attributes must be camelCased (e.g. httpEquiv instead of http-equiv).

Due to a React bug, avoid defer on <script> tags because it can cause hydration warnings. Use async instead.

name​

string

Internal app name.

Must not contain spaces.

server?​

Server

Configuration for the server part of the resulting Wasp app.

spec​

Spec

The specification (Spec) of the app.

Build entries with the dedicated constructors (page, route, query, action, api, apiNamespace, job, crud).

title​

string

App title.

Used as the browser tab title.

wasp​

Wasp

Wasp metadata.

This will get checked against the Wasp CLI.

webSocket?​

WebSocket

Configuration for the app's WebSocket support.

Returns​

App

Example​

import { app, page, route } from '@wasp/spec'
import MainPage from './src/MainPage' with { type: 'ref' }

export default app({
name: 'todoApp',
wasp: { version: "^0.24.0" },
title: "ToDo App",
head: ["<link rel='icon' href='/favicon.ico' />"],
spec: [
route('MainRoute', '/', page(MainPage)),
],
})

Constructors​

action()​

action(fn, config?): Action

Creates an Action definition.

Actions are server-side write operations. Like queries, they can be called from the client and the server. Listing entities in config.entities lets Wasp invalidate related query caches when this action runs.

See Actions.

Parameters​

fn​

Reference<AnyFunction>

Reference to the Action's NodeJS implementation.

See the docs for details on the implementation and its context.

Use reference imports when passing values from your app into the Wasp spec. If a direct import is not practical, use ref as a fallback.

config?​
auth?​

boolean

Whether this Action requires auth. If your app has auth enabled, this defaults to true.

Only available if your app has auth enabled.

entities?​

string[]

A list of entities you wish to use inside your Action.

See Using Entities in Actions.

Returns​

Action

Example​

import { app, action } from "@wasp/spec"
import { createTask } from "./src/actions" with { type: "ref" }
export default app({
// ...
spec: [
action(createTask, { entities: ["Task"] }),
],
})

api()​

api(method, path, fn, config?): Api

Creates an Api endpoint definition.

APIs are custom HTTP endpoints handled by a plain Express function. Use them for webhooks, file uploads, or any HTTP interaction that doesn't fit the query/action model.

See Custom HTTP API Endpoints.

Parameters​

method​

HttpMethod

HTTP method to listen on (or "ALL" for any).

path​

string

Express path the endpoint is mounted at.

fn​

Reference<AnyFunction>

The API's NodeJS implementation.

Use reference imports when passing values from your app into the Wasp spec. If a direct import is not practical, use ref as a fallback.

config?​

Optional settings: middlewareConfigFn, entities, auth.

auth?​

boolean

If true, the handler receives context.user, which is null for requests without an Authorization header. Defaults to true when the app has auth enabled, and false otherwise. Set to false to skip reading the session from the Authorization header.

entities?​

string[]

Entities the handler operates on. Wasp injects a Prisma delegate for each one into the handler's context.entities.

See Using Entities in APIs.

middlewareConfigFn?​

Reference<AnyFunction>

Reference to an Express middleware config function for this endpoint only.

See Configuring API middleware.

Returns​

Api

Example​

import { api } from '@wasp/spec'
import { barBaz } from './src/apis' with { type: 'ref' }

api('GET', '/bar/baz', barBaz, { entities: ['Task'], auth: false })

apiNamespace()​

apiNamespace(path, config): ApiNamespace

Creates an ApiNamespace definition.

Applies a shared middleware function to every api mounted under a given path prefix. Useful for tweaking middleware (e.g. raw body parsing, CORS) for a group of related endpoints.

See the per-path middleware section.

Parameters​

path​

string

Path prefix the namespace applies to.

config​

Required middlewareConfigFn.

Use reference imports when passing values from your app into the Wasp spec. If a direct import is not practical, use ref as a fallback.

middlewareConfigFn​

Reference<AnyFunction>

Reference to an Express middleware config function for this namespace.

Returns​

ApiNamespace

Example​

import { apiNamespace } from '@wasp/spec'
import { barMiddleware } from './src/apis' with { type: 'ref' }

apiNamespace('/bar', { middlewareConfigFn: barMiddleware })

crud()​

crud(name, entity, operations): Crud

Creates a Crud definition.

Auto-generates queries and actions for a Prisma entity. Each operation in operations can be enabled with defaults (an empty object), made public via isPublic, or replaced by a custom implementation via overrideFn.

See Automatic CRUD.

Parameters​

name​

string

Unique name for the generated CRUD.

entity​

string

Name of the Prisma entity to generate operations for.

operations​

CrudOperations

Which operations to generate and how to configure each.

Use reference imports when passing values from your app into the Wasp spec. If a direct import is not practical, use ref as a fallback.

Returns​

Crud

Example​

import { crud } from '@wasp/spec'
import { createTaskOverride } from './src/actions' with { type: 'ref' }

crud('tasks', 'Task', {
getAll: { isPublic: true },
get: {},
create: { overrideFn: createTaskOverride },
update: {},
})

job()​

job(fn, config): Job

Creates a Job definition.

Jobs are background tasks that persist across server restarts, can be retried on failure, delayed, and scheduled with cron. Pass the worker function as the first argument and configure the executor and schedule in config.

See Recurring Jobs.

Parameters​

fn​

Reference<AnyFunction>

The async function that performs the job's work. It receives the submitted args and a context containing the declared entities.

Use reference imports when passing values from your app into the Wasp spec. If a direct import is not practical, use ref as a fallback.

config​

Required executor and optional schedule, entities, and performExecutorOptions.

entities?​

string[]

Entities the worker operates on. Wasp injects a Prisma delegate for each one into the worker's context.entities.

This works like entity access in queries and actions. See Using Entities in Queries.

executor​

"PgBoss"

Executor backing this job.

Currently only "PgBoss" is available.

performExecutorOptions?​

ExecutorOptions

Executor-specific default options used when submitting the job.

These options are passed through to the executor and can be overridden when submitting the job or by Schedule.executorOptions for scheduled runs. For example, with PgBoss this can set retry limits, expiration, or priority.

Default

{}
schedule?​

Schedule

Cron schedule that runs the job automatically.

Returns​

Job

Example​

import { job } from '@wasp/spec'
import { foo } from './src/jobs/bar' with { type: 'ref' }

job(foo, {
executor: 'PgBoss',
entities: ['Task'],
schedule: { cron: '0 * * * *' },
})

page()​

page(component, config?): Page

Creates a Page definition.

A page is a React component rendered by a route.

See Pages & Routes and the Auth overview for protecting pages with authRequired.

Parameters​

component​

Reference<AnyFunction>

The React component to render.

Use reference imports when passing values from your app into the Wasp spec. If a direct import is not practical, use ref as a fallback.

config?​

Optional page settings such as authRequired.

authRequired?​

boolean

If true, only authenticated users can access this page. Unauthenticated visitors are redirected to Auth.onAuthFailedRedirectTo.

Cannot be combined with Route.prerender.

Default

false

Returns​

Page

Example​

import { page } from '@wasp/spec'
import MainPage from './src/MainPage' with { type: 'ref' }

page(MainPage, { authRequired: true })

query()​

query(fn, config?): Query

Creates a Query definition.

Queries are server-side read-only operations. They can be invoked from the client (with caching via useQuery) and the server. List the entities the query reads from so Wasp can inject the matching Prisma delegates into context.entities and invalidate the client cache when related actions modify them.

See Queries.

Parameters​

fn​

Reference<AnyFunction>

Reference to the Query's NodeJS implementation.

See the docs for details on the implementation and its context.

Use reference imports when passing values from your app into the Wasp spec. If a direct import is not practical, use ref as a fallback.

config?​
auth?​

boolean

Whether this Query requires auth. If your app has auth enabled, this defaults to true.

Only available if your app has auth enabled.

entities?​

string[]

A list of entities you wish to use inside your Query.

See Using Entities in Queries.

Returns​

Query

Example​

import { app, query } from "@wasp/spec"
import { getTasks } from './src/queries' with { type: 'ref' }

export default app({
// ...
spec: [
query(getTasks, { entities: ["Foo"] }),
],
})

route()​

route(name, path, page, config?): Route

Creates a Route definition.

Maps a URL path to a Page. Paths support React Router patterns such as dynamic segments (/tasks/:id), optional segments (/photo/:id/edit?), and splats (/files/*).

Use config.prerender to render the route to static HTML at build time: true prerenders the route's own static path, or pass an array of concrete paths to prerender specific instances of a dynamic route (see Prerendering). Use config.lazy to opt out of lazy-loading the page's bundle.

Parameters​

name​

string

Unique name for the route.

path​

string

URL path the route matches.

page​

Page

The result of page().

config?​

Optional route settings (lazy, prerender).

lazy?​

boolean

Lazy-load the page's component.

Set to false to include the page in the initial client bundle, which avoids the brief loading delay on first navigation at the cost of a larger initial download.

Default

true
prerender?​

boolean | readonly string[]

Render this route to static HTML at build time. Useful for SEO and AI crawlers. The page then hydrates on the client for full interactivity.

Accepts either:

  • true — prerender this route's own path. The path must be fully static (no :paramName, *, or ? segments).
  • an array of concrete paths to prerender. Use this to prerender specific instances of a dynamic route (e.g. ["/blog/intro", "/blog/changelog"] for a "/blog/:slug" route). Every listed path must be fully static and must match this route's path pattern.

In either case the route's page cannot have Page.authRequired set, since prerendered content can't depend on the logged-in user. See Prerendering.

Default

false

Example

import { app, page, route } from "@wasp/spec"
import { LandingPage } from "./src/LandingPage" with { type: "ref" }
import { BlogPostPage } from "./src/BlogPostPage" with { type: "ref" }

export default app({
// ...
spec: [
route("LandingRoute", "/", page(LandingPage), {
prerender: true,
}),
route("BlogPostRoute", "/blog/:slug", page(BlogPostPage), {
prerender: ["/blog/intro", "/blog/changelog"],
}),
],
})

Returns​

Route

Example​

import { page, route } from '@wasp/spec'
import MainPage from './src/MainPage' with { type: 'ref' }

route('MainRoute', '/', page(MainPage))

Specifications​

Action​

A server-side write operation, callable from the client and the server.

Create one with the action constructor.

See Actions.

Extends​

Properties​

auth?​

optional auth?: boolean

Whether this Action requires auth. If your app has auth enabled, this defaults to true.

Only available if your app has auth enabled.

entities?​

optional entities?: string[]

A list of entities you wish to use inside your Action.

See Using Entities in Actions.

fn​

fn: Reference<AnyFunction>

Reference to the Action's NodeJS implementation.

See the docs for details on the implementation and its context.

kind​

kind: "action"

The internal Wasp type of a SpecElement. Used by the compiler. You should not set this field directly, instead use the dedicated constructors.

Inherited from​

BaseSpecElement.kind


Api​

A custom HTTP endpoint mounted on the Wasp server.

Create one with the api constructor.

Unlike operations, APIs are plain Express handlers that receive req, res, and a Wasp context. They are useful for webhooks and any non-standard HTTP interaction.

See Custom HTTP API Endpoints.

Extends​

Properties​

auth?​

optional auth?: boolean

If true, the handler receives context.user, which is null for requests without an Authorization header. Defaults to true when the app has auth enabled, and false otherwise. Set to false to skip reading the session from the Authorization header.

entities?​

optional entities?: string[]

Entities the handler operates on. Wasp injects a Prisma delegate for each one into the handler's context.entities.

See Using Entities in APIs.

fn​

fn: Reference<AnyFunction>

Reference to the API's NodeJS implementation.

kind​

kind: "api"

The internal Wasp type of a SpecElement. Used by the compiler. You should not set this field directly, instead use the dedicated constructors.

Inherited from​

BaseSpecElement.kind

method​

method: HttpMethod

HTTP method this endpoint responds to.

middlewareConfigFn?​

optional middlewareConfigFn?: Reference<AnyFunction>

Reference to an Express middleware config function for this endpoint only.

See Configuring API middleware.

path​

path: string

Express path of the endpoint (e.g. "/webhooks/stripe").


ApiNamespace​

Shared middleware applied to every Api mounted under a path prefix.

Create one with the apiNamespace constructor.

Extends​

Properties​

kind​

kind: "apiNamespace"

The internal Wasp type of a SpecElement. Used by the compiler. You should not set this field directly, instead use the dedicated constructors.

Inherited from​

BaseSpecElement.kind

middlewareConfigFn​

middlewareConfigFn: Reference<AnyFunction>

Reference to an Express middleware config function for this namespace.

path​

path: string

Path prefix the namespace applies to (e.g. "/webhooks").


Crud​

Auto-generated CRUD operations for an entity.

Create one with the crud constructor.

See Automatic CRUD.

Extends​

Properties​

entity​

entity: string

Entity to generate operations for.

kind​

kind: "crud"

The internal Wasp type of a SpecElement. Used by the compiler. You should not set this field directly, instead use the dedicated constructors.

Inherited from​

BaseSpecElement.kind

name​

name: string

Unique name for this CRUD.

operations​

operations: CrudOperations

Which operations to generate and how to configure each one.


Job​

A background job. Can be submitted ad-hoc or run on a recurring schedule.

Create one with the job constructor.

See Recurring Jobs.

Extends​

Properties​

entities?​

optional entities?: string[]

Entities the worker operates on. Wasp injects a Prisma delegate for each one into the worker's context.entities.

This works like entity access in queries and actions. See Using Entities in Queries.

executor​

executor: "PgBoss"

Executor backing this job.

Currently only "PgBoss" is available.

fn​

fn: Reference<AnyFunction>

Reference to the job's NodeJS implementation. It receives the submitted args and a context containing the declared entities.

See Jobs documentation for more details.

kind​

kind: "job"

The internal Wasp type of a SpecElement. Used by the compiler. You should not set this field directly, instead use the dedicated constructors.

Inherited from​

BaseSpecElement.kind

performExecutorOptions?​

optional performExecutorOptions?: ExecutorOptions

Executor-specific default options used when submitting the job.

These options are passed through to the executor and can be overridden when submitting the job or by Schedule.executorOptions for scheduled runs. For example, with PgBoss this can set retry limits, expiration, or priority.

Default​
{}
schedule?​

optional schedule?: Schedule

Cron schedule that runs the job automatically.


Page​

A page in the app, normally a React component rendered for a Route.

Create one with the page constructor.

Extends​

Properties​

authRequired?​

optional authRequired?: boolean

If true, only authenticated users can access this page. Unauthenticated visitors are redirected to Auth.onAuthFailedRedirectTo.

Cannot be combined with Route.prerender.

Default​
false
component​

component: Reference<AnyFunction>

React component rendered for this page.

kind​

kind: "page"

The internal Wasp type of a SpecElement. Used by the compiler. You should not set this field directly, instead use the dedicated constructors.

Inherited from​

BaseSpecElement.kind


Query​

A server-side read-only operation, callable from the client and the server.

Create one with the query constructor.

See Queries.

Extends​

Properties​

auth?​

optional auth?: boolean

Whether this Query requires auth. If your app has auth enabled, this defaults to true.

Only available if your app has auth enabled.

entities?​

optional entities?: string[]

A list of entities you wish to use inside your Query.

See Using Entities in Queries.

fn​

fn: Reference<AnyFunction>

Reference to the Query's NodeJS implementation.

See the docs for details on the implementation and its context.

kind​

kind: "query"

The internal Wasp type of a SpecElement. Used by the compiler. You should not set this field directly, instead use the dedicated constructors.

Inherited from​

BaseSpecElement.kind


Route​

A URL path mapped to a Page.

Create one with the route constructor.

See Pages & Routes for path patterns (dynamic segments, optional segments, splats).

Extends​

Properties​

kind​

kind: "route"

The internal Wasp type of a SpecElement. Used by the compiler. You should not set this field directly, instead use the dedicated constructors.

Inherited from​

BaseSpecElement.kind

lazy?​

optional lazy?: boolean

Lazy-load the page's component.

Set to false to include the page in the initial client bundle, which avoids the brief loading delay on first navigation at the cost of a larger initial download.

Default​
true
name​

name: string

Unique route name.

page​

page: Page

Page rendered when this route matches.

path​

path: string

URL path. Supports React Router patterns like /tasks/:id, /photo/:id/edit?, and /files/*.

prerender?​

optional prerender?: boolean | readonly string[]

Render this route to static HTML at build time. Useful for SEO and AI crawlers. The page then hydrates on the client for full interactivity.

Accepts either:

  • true — prerender this route's own path. The path must be fully static (no :paramName, *, or ? segments).
  • an array of concrete paths to prerender. Use this to prerender specific instances of a dynamic route (e.g. ["/blog/intro", "/blog/changelog"] for a "/blog/:slug" route). Every listed path must be fully static and must match this route's path pattern.

In either case the route's page cannot have Page.authRequired set, since prerendered content can't depend on the logged-in user. See Prerendering.

Default​
false
Example​
import { app, page, route } from "@wasp/spec"
import { LandingPage } from "./src/LandingPage" with { type: "ref" }
import { BlogPostPage } from "./src/BlogPostPage" with { type: "ref" }

export default app({
// ...
spec: [
route("LandingRoute", "/", page(LandingPage), {
prerender: true,
}),
route("BlogPostRoute", "/blog/:slug", page(BlogPostPage), {
prerender: ["/blog/intro", "/blog/changelog"],
}),
],
})

Spec​

Spec = SpecElement | Spec[]

A single SpecElement, or an (optionally nested) array of them, that makes up the App.spec.

This lets you define related elements separately (for example, one array per feature) and compose them together. The nested structure is treated as a single flat list of elements.

Example​

Nested arrays let you compose a spec from separate sub-specs:

import { app } from "@wasp/spec"

const authSpec: Spec = [signupRoute, loginRoute];
const tasksSpec: Spec = [tasksRoute, getTasks, createTask];

export default app({
// ...
spec: [authSpec, tasksSpec],
});

SpecElement​

SpecElement = Page | Route | Query | Action | Api | ApiNamespace | Job | Crud

Union of every kind of specification element that can appear in App.spec.

Each variant is produced by its matching constructor.

References​

DefaultRefObjectDescriptor​

Default import reference, equivalent to import SomeValue from "./src/someModule" with { type: "ref" }.

Properties​

from​

from: string

Module path, relative to the *.wasp.ts file using it.

importDefault​

importDefault: string

Local name for the default import.


NamedRefObjectDescriptor​

Named import reference, equivalent to import { SomeValue } from "./src/someModule" with { type: "ref" }.

Properties​

alias?​

optional alias?: string

Optional local alias.

Alias takes precedence over the import field when Wasp Spec dervies some WaspSpec.SpecElement name.

from​

from: string

Module path, relative to the *.wasp.ts file using it.

import​

import: string

Exported name to import.


Reference​

Reference<AppValue> = RefObject | AppValue

Represents a value from your app passed into the Wasp spec.

Use reference imports when passing values from your app into the Wasp spec. If a direct import is not practical, use ref as a fallback.

Type Parameters​

AppValue​

AppValue

The expected TypeScript type for the value from your app. The field using Reference<AppValue> decides this type. For example, Page.component expects a React component, Query.fn expects a server function, and env schema fields expect a ZodSchema.

Example​

import { app, query } from "@wasp/spec"
import { getTasks } from "./src/queries" with { type: "ref" }

export default app({
// ...
spec: [
query(getTasks, { entities: ["Task"] }),
],
})

RefObject​

RefObject = Branded<RefObjectDescriptor & object, "RefObject">

A reference to code in your app's src directory.


RefObjectDescriptor​

RefObjectDescriptor = NamedRefObjectDescriptor | DefaultRefObjectDescriptor

Input accepted by ref.


ZodSchema​

ZodSchema = object

Structural type for a runtime Zod schema accepted by Wasp env validation fields.

Use reference imports when passing values from your app into the Wasp spec. If a direct import is not practical, use ref as a fallback.

See Server.envValidationSchema and Client.envValidationSchema for examples.

To avoid depending on the zod package, Wasp structurally recognizes Zod 4 schemas via their documented library-author marker. See https://zod.dev/library-authors.

Properties​

_zod​

readonly _zod: object

def​

readonly def: object


ref()​

ref(_descriptor): RefObject

Creates a fallback reference object for a value from your app.

Use reference imports when passing values from your app into the Wasp spec. If a direct import is not practical, use ref as a fallback.

Reference imports are preferred because editors can follow and rename real imports.

The import path must be relative to the *.wasp.ts file where it is used and resolve inside the app's src/ directory. Absolute paths are not supported.

Parameters​

_descriptor​

RefObjectDescriptor

Returns​

RefObject

Example​

import { page, ref } from "@wasp/spec"

const MainPage = ref({
importDefault: "MainPage",
from: "./src/MainPage",
})

export const mainPage = page(MainPage)

Errors​

WaspSpecUserError​

Error caused by invalid user input (unknown entities, bad imports, etc.).

Wasp's spec pipeline throws WaspSpecUserError when it finds a problem with the user's configuration. Its message is reported to the user as a clean, actionable error instead of an internal stack trace.

Throw it from your own spec helper libraries when you want to report a configuration problem the same way Wasp does:

Example​

import { WaspSpecUserError } from "@wasp/spec"

export function requireEnv(name: string): string {
const value = process.env[name]
if (value === undefined) {
throw new WaspSpecUserError(`Missing required environment variable '${name}'.`)
}
return value
}

These are the errors users hit most often during development, so keep their messages short, clear, and actionable.

Extends​

  • Error

Constructors​

Constructor​

new WaspSpecUserError(message?): WaspSpecUserError

Parameters​
message?​

string

Returns​

WaspSpecUserError

Inherited from​

Error.constructor

Constructor​

new WaspSpecUserError(message?, options?): WaspSpecUserError

Parameters​
message?​

string

options?​

ErrorOptions

Returns​

WaspSpecUserError

Inherited from​

Error.constructor

Fields​

Auth​

Authentication configuration and lifecycle hooks.

See the Auth overview for the supported auth methods and how the User entity is connected to auth. If hooks are async, Wasp awaits them. All hooks receive prisma and req in their input. Hook return values are ignored except for AuthHooks.onBeforeOAuthRedirect, which can change the redirect URL.

In TypeScript, you can type each hook implementation with its matching type from wasp/server/auth (e.g. OnBeforeSignupHook). See Auth Hooks for the full hook inputs and examples.

Example​

import { app } from "@wasp/spec"

export default app({
// ...
auth: {
userEntity: "User",
methods: {
usernameAndPassword: {}, // use this or email, not both
google: {},
gitHub: {},
},
onAuthFailedRedirectTo: "/login",
},
})

Extends​

Fields​

methods​

methods: AuthMethods

Enabled authentication methods.

onAfterEmailVerified?​

optional onAfterEmailVerified?: Reference<AnyFunction>

Called after the user verifies their email. Receives email and user.

Inherited from​

AuthHooks.onAfterEmailVerified

onAuthFailedRedirectTo​

onAuthFailedRedirectTo: string

Route that Wasp redirects unauthenticated users to when they try to access a page that has authRequired: true.

See Adding Auth to the Project for an example.

onAuthSucceededRedirectTo?​

optional onAuthSucceededRedirectTo?: string

Route that Wasp redirects users to after a successful login or signup.

Only takes effect when using Wasp's built-in Auth UI.

See Auth UI.

Default​
"/"
userEntity​

userEntity: string

Name of the Prisma model that represents the application user connected to your business logic.

The user entity needs to have an ID field that uniquely identifies each user. It can be of any name and type, but it needs to be marked with @id:

schema.prisma
model User {
id Int @id @default(autoincrement())
}

You can add any other fields you want to the user entity. Make sure to also define them in the userSignupFields field if they need to be set during the sign-up process.

See Accessing User Data for how the user entity connects to the rest of the auth system.

Hooks​

onAfterLogin?​

optional onAfterLogin?: Reference<AnyFunction>

Called after a successful login. Receives providerId, user, and, for social auth, oauth fields including tokens and the unique OAuth request ID.

Inherited from​

AuthHooks.onAfterLogin

onAfterSignup?​

optional onAfterSignup?: Reference<AnyFunction>

Called after the user is created. Receives providerId, the created user, and, for social auth, oauth fields including tokens and the unique OAuth request ID.

Inherited from​

AuthHooks.onAfterSignup

onBeforeLogin?​

optional onBeforeLogin?: Reference<AnyFunction>

Called before the user is logged in. Receives providerId and user. Throw from this hook to reject a login based on custom criteria.

Inherited from​

AuthHooks.onBeforeLogin

onBeforeOAuthRedirect?​

optional onBeforeOAuthRedirect?: Reference<AnyFunction>

Called before redirecting the user to the OAuth provider. Receives the generated url and oauth.uniqueRequestId. Return { url } to override the redirect URL.

Inherited from​

AuthHooks.onBeforeOAuthRedirect

onBeforeSignup?​

optional onBeforeSignup?: Reference<AnyFunction>

Called before the user is created. Receives providerId plus the common hook input. Throw from this hook to reject a signup based on custom criteria.

Inherited from​

AuthHooks.onBeforeSignup


Client​

Client-side application configuration.

See Client Config for usage details.

Example​

import { app } from "@wasp/spec"
import Root from "./src/Root" with { type: "ref" }
import mySetupFunction from "./src/myClientSetupCode" with { type: "ref" }

export default app({
// ...
client: {
rootComponent: Root,
setupFn: mySetupFunction,
baseDir: "/my-app",
},
})

Properties​

baseDir?​

optional baseDir?: `/${string}`

If you need to serve the client from a subdirectory, you can use the baseDir option.

If you set baseDir to /my-app for example, that will make Wasp set the basename prop of the Router to /my-app. It will also set the base option of the Vite config to /my-app.

This means that if you serve your app from https://example.com/my-app, the router will work correctly, and all the assets will be served from https://example.com/my-app.

Check the Base directory docs for important details.

envValidationSchema?​

optional envValidationSchema?: Reference<{ _zod: { def: object; }; }>

Zod schema used to validate user-defined client environment variables when Vite starts and when the client code loads. Wasp merges it with built-in validation for Wasp-defined env vars when validating import.meta.env. Client env vars must be prefixed with REACT_APP_. Define the schema with defineEnvValidationSchema from wasp/env to make sure it is type-checked.

Use reference imports when passing values from your app into the Wasp spec. If a direct import is not practical, use ref as a fallback.

For example:

import { clientEnvSchema } from './src/env' with { type: 'ref' }

See Env Vars.

rootComponent?​

optional rootComponent?: Reference<AnyFunction>

Wrapper React component rendered at the root of the client app. Must render either <Outlet> from react-router or the children prop to show the current page.

Useful for layouts, providers (Redux, theme, etc.), and global UI.

Example​
import { Outlet } from "react-router"
import store from "./store"
import { Provider } from "react-redux"

export default function Root() {
return (
<Provider store={store}>
<Layout />
</Provider>
)
}

function Layout() {
return (
<div>
<header>
<h1>My App</h1>
</header>

{/* The current page will be rendered here */}
<Outlet />

<footer>
<p>My App footer</p>
</footer>
</div>
)
}
setupFn?​

optional setupFn?: Reference<AnyFunction>

Async function Wasp calls once while initializing the client app. Wasp awaits it before rendering the app. It receives no arguments, and its return value is ignored. Use it for one-time client-side setup, such as configuring the query client or starting client-side periodic jobs.

Example​
export default async function mySetupFunction(): Promise<void> {
// Run some code
}

CrudOperationOptions​

Configuration for a single CRUD operation.

Properties​

isPublic?​

optional isPublic?: boolean

If true, the operation skips Wasp's auth check and can be called by anyone.

Default​
false
overrideFn?​

optional overrideFn?: Reference<AnyFunction>

Reference to a custom implementation that replaces Wasp's auto-generated one. Use this when you need custom business logic for an operation (e.g. attaching userId on create).

See the CRUD guide for an override example.

The override receives the caller-provided args payload and a Wasp-provided context containing the current user and the entity being operated on.

Important Use an override to validate or filter input before saving it; the default create and update implementations pass client-sent data to Prisma.

Wasp doesn't check auth for an override, and isPublic has no effect on it, so check context.user yourself.


CrudOperations​

Mapping of CRUD operations to their options.

Each key enables the matching operation; an empty object enables it with Wasp's defaults.

The default implementations map directly to Prisma calls on the entity, and use the field marked with @id in the Prisma schema as the entity ID. Unless an operation is marked with CrudOperationOptions.isPublic, its default implementation checks that an authenticated user is making the request.

CRUD operations are implemented with Wasp queries and actions. See Operations.

Properties​

create?​

optional create?: CrudOperationOptions

Default​

Entity.create({ data: args })

delete?​

optional delete?: CrudOperationOptions

Default​

Entity.delete({ where: { id: args.id } })

get?​

optional get?: CrudOperationOptions

Default​

Entity.findUnique({ where: { id: args.id } })

getAll?​

optional getAll?: CrudOperationOptions

Default​

Entity.findMany()

update?​

optional update?: CrudOperationOptions

Default​

Entity.update({ where: { id }, data }), where { id, ...data } = args


Db​

Database configuration.

See Databases for seeding and Prisma client customization.

Example​

import { app } from "@wasp/spec"
import devSeed from "./src/dbSeeds" with { type: "ref" }
import { setUpPrisma } from "./src/prisma" with { type: "ref" }

export default app({
// ...
db: {
seeds: [devSeed],
prismaSetupFn: setUpPrisma,
},
})

Properties​

prismaSetupFn?​

optional prismaSetupFn?: Reference<AnyFunction>

Function that sets up and returns a configured Prisma Client instance. Use this to add Prisma logging or client extensions.

See Prisma's logging and client extensions docs.

Example​
import { PrismaClient } from "@prisma/client"

export const setUpPrisma = () => {
const prisma = new PrismaClient({
log: ["query", "info", "warn", "error"],
})

return prisma
}
seeds?​

optional seeds?: Reference<AnyFunction>[]

Async functions runnable with wasp db seed [name] to populate the database with initial data. Each function receives Wasp's Prisma Client; the name passed to wasp db seed matches the function's identifier in the import.

See Seeding the Database.


Deployment​

Deployment configuration for the app.

Properties​

mode?​

optional mode?: "split"

How the client and server are deployed.

Default​
"split"

EmailAuthConfig​

Email auth configuration.

See the Email auth docs for the full signup, verification, and password reset flows.

Example​

import { app } from "@wasp/spec"
import { userSignupFields } from "./src/auth" with { type: "ref" }
import {
getVerificationEmailContent,
getPasswordResetEmailContent,
} from "./src/auth/email" with { type: "ref" }

export default app({
// ...
auth: {
userEntity: "User",
methods: {
email: {
userSignupFields,
fromField: {
name: "My App",
email: "hello@itsme.com",
},
emailVerification: {
clientRoute: "EmailVerificationRoute",
getEmailContentFn: getVerificationEmailContent,
},
passwordReset: {
clientRoute: "PasswordResetRoute",
getEmailContentFn: getPasswordResetEmailContent,
},
},
},
onAuthFailedRedirectTo: "/login",
},
})

Extends​

Properties​

emailVerification​

emailVerification: EmailFlowConfig

An object that specifies the details of the e-mail verification process.

fromField​

fromField: EmailFromField

Sender identity used for verification and password reset emails.

passwordReset​

passwordReset: EmailFlowConfig

An object that specifies the password reset process.

passwordValidationSchema?​

optional passwordValidationSchema?: Reference<{ _zod: { def: object; }; }>

Zod string schema that new passwords must pass on signup and password reset. Wasp uses its default rules when it's not set.

Inherited from​

LocalAuthMethodConfig.passwordValidationSchema

userSignupFields?​

optional userSignupFields?: Reference<AnyObject>

Object that defines extra fields to save on the user during signup (e.g. firstName, address). Each field name must exist on the configured Auth.userEntity.

Each field function receives the data sent from the client and returns the value Wasp saves to the database. For social auth, this data includes provider-specific profile information. If the value is invalid, throw an error. The password field is excluded from this object and handled by Wasp's auth backend.

See defineUserSignupFields.

Example​
import { defineUserSignupFields } from 'wasp/server/auth'

export const userSignupFields = defineUserSignupFields({
address: (data) => {
if (!data.address) {
throw new Error('Address is required')
}
return data.address
},
phone: (data) => data.phone,
})
Inherited from​

LocalAuthMethodConfig.userSignupFields


EmailFlowConfig​

Configuration for an email-based auth flow (verification or password reset).

Properties​

clientRoute​

clientRoute: string

Name of the route that handles the link sent in the email (e.g. "EmailVerificationRoute" or "PasswordResetRoute").

The route must be defined in App.spec with the route constructor.

This route should handle the process of taking a token from the URL and sending it to the server to verify the e-mail address. You can use our verifyEmail action and resetPassword action helpers for that.

getEmailContentFn?​

optional getEmailContentFn?: Reference<AnyFunction>

Function that returns the email content (subject, html, text) Wasp sends for this flow. Verification email functions receive { verificationLink }, and password reset email functions receive { passwordResetLink }. If omitted, Wasp uses a built-in default template.

In TypeScript, you can type the function with the GetVerificationEmailContentFn or GetPasswordResetEmailContentFn type from wasp/server/auth.

Example​
src/email.ts
import { GetVerificationEmailContentFn } from "wasp/server/auth"

export const getVerificationEmailContent: GetVerificationEmailContentFn = ({
verificationLink,
}) => ({
subject: "Verify your email",
text: `Click the link below to verify your email: ${verificationLink}`,
html: `
<p>Click the link below to verify your email</p>
<a href="${verificationLink}">Verify email</a>
`,
})

EmailFromField​

Sender identity used in outgoing emails.

Properties​

email​

email: string

Email address the message is sent from.

name?​

optional name?: string

Optional display name shown alongside the email address.


EmailSender​

Email sender configuration.

Required for the email auth flows (verification, password reset) and available for sending arbitrary emails via wasp/server/email.

See Sending Emails.

Example​

import { app } from "@wasp/spec"

export default app({
// ...
emailSender: {
provider: "SMTP",
defaultFrom: {
name: "Example",
email: "hello@itsme.com",
},
},
})

Properties​

defaultFrom?​

optional defaultFrom?: EmailFromField

The default sender's details. If you set this field, you don't need to provide the from field when sending an email.

provider​

provider: EmailSenderProviderName

Provider Wasp uses to deliver outgoing emails.


ExecutorOptions​

Executor-specific options.

The pgBoss field is forwarded as-is to the matching pg-boss API. See the pg-boss send options docs for the supported keys.

Properties​

pgBoss​

pgBoss: object


ExternalAuthMethods​

Social (OAuth) auth methods.

Each enabled provider also requires the matching client ID and secret to be set as environment variables. See the Social Auth overview for details on each provider.

Extends​

Properties​

discord?​

optional discord?: SocialAuthConfig

Inherited from​

ExternalAuthMethods.discord

gitHub?​

optional gitHub?: SocialAuthConfig

Inherited from​

ExternalAuthMethods.gitHub

google?​

optional google?: SocialAuthConfig

Inherited from​

ExternalAuthMethods.google

keycloak?​

optional keycloak?: SocialAuthConfig

Inherited from​

ExternalAuthMethods.keycloak

microsoft?​

optional microsoft?: SocialAuthConfig

Inherited from​

ExternalAuthMethods.microsoft

slack?​

optional slack?: SocialAuthConfig

Inherited from​

ExternalAuthMethods.slack


LocalAuthMethods​

Built-in local auth methods.

Pick at most one of these.

Properties​

email​

email: EmailAuthConfig

Enables email and password auth with email verification and password reset flows.

usernameAndPassword​

usernameAndPassword: UsernameAndPasswordConfig

Enables username and password auth.


Schedule​

Cron schedule for a Job.

Properties​

args?​

optional args?: object

Arguments passed to the worker function on each scheduled run.

cron​

cron: string

Five-field cron expression (e.g. "0 * * * *" for hourly).

Wasp supports minute-level precision.

See pg-boss's scheduling docs for the rationale. Use Crontab Guru to build cron expressions.

executorOptions?​

optional executorOptions?: ExecutorOptions

Executor-specific options applied only to scheduled runs. These override or extend Job.performExecutorOptions.


Server​

Server-side application configuration.

See Server Config for usage details.

Example​

import { app } from "@wasp/spec"
import { myMiddlewareConfigFn, mySetupFunction } from "./src/myServerSetupCode" with { type: "ref" }

export default app({
// ...
server: {
setupFn: mySetupFunction,
middlewareConfigFn: myMiddlewareConfigFn,
},
})

Properties​

envValidationSchema?​

optional envValidationSchema?: Reference<{ _zod: { def: object; }; }>

Zod schema used to validate user-defined server environment variables on startup. Wasp merges it with built-in validation for Wasp-defined env vars when validating process.env. Define the schema with defineEnvValidationSchema from wasp/env to make sure it is type-checked.

Use reference imports when passing values from your app into the Wasp spec. If a direct import is not practical, use ref as a fallback.

For example:

import { serverEnvSchema } from './src/env' with { type: 'ref' }

See Env Vars.

middlewareConfigFn?​

optional middlewareConfigFn?: Reference<AnyFunction>

Function that customizes the global Express middleware stack. Affects all operations and APIs.

See Configuring Middleware.

setupFn?​

optional setupFn?: Reference<AnyFunction>

Async function called once on server start. Wasp awaits it before the server accepts requests. Receives a context containing the Express app and underlying http.Server, so you can register custom routes, set up additional databases or WebSockets, or kick off scheduled jobs.

In TypeScript, you can type the function with the ServerSetupFn type from wasp/server.

Example​
import { type ServerSetupFn } from "wasp/server"

export const mySetupFunction: ServerSetupFn = async () => {
await setUpSomeResource()
}
traceDeps?​

optional traceDeps?: string[]

Extra packages to copy into the server's Docker image.

The Docker image contains only the files the server imports. A package that loads files in a non-standard way (for example, static assets it serves from its own folder) can miss some of them. Each entry is a package name with an optional prefix or suffix, the same syntax as Nitro's traceDeps:

  • "pkg" traces the package even when the server doesn't import it.
  • "pkg*" copies all of the package's files.
  • "!pkg" stops copying all files of a package Wasp copies fully by default.

We use nf3, which finds most of the files your dependencies need by default. Only use this setting if you've confirmed a necessary file is missing.

Example​
traceDeps: ["swagger-ui-dist*"]
See​

SocialAuthConfig​

Social auth provider configuration.

By default, Wasp stores only the user's provider-specific ID. Use userSignupFields to save provider account details or custom signup state on your Auth.userEntity. Each provider has provider-specific userSignupFields and configFn behavior, documented in the Social Auth docs.

Example​

import { app } from "@wasp/spec"
import { getConfig, userSignupFields } from "./src/auth/google" with { type: "ref" }

export default app({
// ...
auth: {
userEntity: "User",
methods: {
google: {
configFn: getConfig,
userSignupFields,
},
},
onAuthFailedRedirectTo: "/login",
},
})

Extends​

Properties​

configFn?​

optional configFn?: Reference<AnyFunction>

Function that returns provider-specific OAuth options (scopes, prompt, etc.). Use this to request extra scopes, such as requesting email/profile data from providers that do not include it by default, or to customize the OAuth flow.

Example​
export function getConfig() {
return {
scopes: ["openid", "profile", "email"],
}
}
userSignupFields?​

optional userSignupFields?: Reference<AnyObject>

Object that defines extra fields to save on the user during signup (e.g. firstName, address). Each field name must exist on the configured Auth.userEntity.

Each field function receives the data sent from the client and returns the value Wasp saves to the database. For social auth, this data includes provider-specific profile information. If the value is invalid, throw an error. The password field is excluded from this object and handled by Wasp's auth backend.

See defineUserSignupFields.

Example​
import { defineUserSignupFields } from 'wasp/server/auth'

export const userSignupFields = defineUserSignupFields({
address: (data) => {
if (!data.address) {
throw new Error('Address is required')
}
return data.address
},
phone: (data) => data.phone,
})
Inherited from​

BaseAuthMethodConfig.userSignupFields


UsernameAndPasswordConfig​

Username and password auth configuration.

Example​

import { app } from "@wasp/spec"
import { userSignupFields } from "./src/auth" with { type: "ref" }

export default app({
// ...
auth: {
userEntity: "User",
methods: {
usernameAndPassword: {
userSignupFields,
},
},
onAuthFailedRedirectTo: "/login",
},
})

Extends​

Properties​

passwordValidationSchema?​

optional passwordValidationSchema?: Reference<{ _zod: { def: object; }; }>

Zod string schema that new passwords must pass on signup and password reset. Wasp uses its default rules when it's not set.

Inherited from​

LocalAuthMethodConfig.passwordValidationSchema

userSignupFields?​

optional userSignupFields?: Reference<AnyObject>

Object that defines extra fields to save on the user during signup (e.g. firstName, address). Each field name must exist on the configured Auth.userEntity.

Each field function receives the data sent from the client and returns the value Wasp saves to the database. For social auth, this data includes provider-specific profile information. If the value is invalid, throw an error. The password field is excluded from this object and handled by Wasp's auth backend.

See defineUserSignupFields.

Example​
import { defineUserSignupFields } from 'wasp/server/auth'

export const userSignupFields = defineUserSignupFields({
address: (data) => {
if (!data.address) {
throw new Error('Address is required')
}
return data.address
},
phone: (data) => data.phone,
})
Inherited from​

LocalAuthMethodConfig.userSignupFields


Wasp​

Wasp compiler metadata used by the app.

Properties​

version​

version: string

The Wasp version this app is built for, as an npm-compatible SemVer range (e.g. "^0.24.0").


WebSocket​

WebSocket configuration.

See WebSockets for handler shape and client-side usage.

Example​

import { app } from "@wasp/spec"
import { webSocketFn } from "./src/webSocket" with { type: "ref" }

export default app({
// ...
webSocket: {
fn: webSocketFn,
autoConnect: true,
},
})

Properties​

autoConnect?​

optional autoConnect?: boolean

If true (the default), the client connects to the WebSocket server as soon as the app loads. Set to false to connect manually via useSocket.

Default​
true
fn​

fn: Reference<AnyFunction>

Function that registers Socket.IO event handlers. Wasp calls it once on server start with the Socket.IO server instance and a context containing all app entities. If a connected socket is authenticated, Wasp stores the user on socket.data.user.

See the webSocketFn docs.


ActionConfig​

ActionConfig = Omit<Action, "kind" | "fn">

The optional configuration object accepted as the last argument of the action constructor.


ApiConfig​

ApiConfig = Omit<Api, "kind" | "method" | "path" | "fn">

The optional configuration object accepted as the last argument of the api constructor.


ApiNamespaceConfig​

ApiNamespaceConfig = Omit<ApiNamespace, "kind" | "path">

The configuration object accepted as the last argument of the apiNamespace constructor.


AuthMethods​

AuthMethods = RequireOneOrNone<LocalAuthMethods> & ExternalAuthMethods

Enabled authentication methods for the app.

At most one local auth method (LocalAuthMethods) can be used, but you can enable as many external auth methods (ExternalAuthMethods) as you need.


DeploymentMode​

DeploymentMode = "split"

Supported app deployment modes.


EmailSenderProviderName​

EmailSenderProviderName = "SMTP" | "SendGrid" | "Mailgun" | "Resend" | "Dummy"

Supported email sender providers.

"Dummy" logs emails to the console instead of sending them, which is convenient during development, but not allowed in production.


EntityName​

EntityName = keyof Entities extends never ? string : Extract<keyof Entities, string>

One of the app's entity names, matching a model in schema.prisma.


HttpMethod​

HttpMethod = "ALL" | "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD"

HTTP methods supported by an Api.

Use "ALL" to match any method.

A "HEAD" api must be declared before a "GET" api on the same path, otherwise the "GET" api answers the HEAD requests as well.


JobConfig​

JobConfig = Omit<Job, "kind" | "fn">

The configuration object accepted as the last argument of the job constructor.


JobExecutor​

JobExecutor = "PgBoss"

Supported job executors.

Currently only "PgBoss" is available, which stores jobs in the app's PostgreSQL database via pg-boss.


PageConfig​

PageConfig = Omit<Page, "kind" | "component">

The optional configuration object accepted as the last argument of the page constructor.


QueryConfig​

QueryConfig = Omit<Query, "kind" | "fn">

The optional configuration object accepted as the last argument of the query constructor.


RouteConfig​

RouteConfig = Omit<Route, "kind" | "name" | "path" | "page">

The optional configuration object accepted as the last argument of the route constructor.

Referenced Types​

AuthHooks​

Extended by​

Fields​

onAfterEmailVerified?​

optional onAfterEmailVerified?: Reference<AnyFunction>

Called after the user verifies their email. Receives email and user.

Hooks​

onAfterLogin?​

optional onAfterLogin?: Reference<AnyFunction>

Called after a successful login. Receives providerId, user, and, for social auth, oauth fields including tokens and the unique OAuth request ID.

onAfterSignup?​

optional onAfterSignup?: Reference<AnyFunction>

Called after the user is created. Receives providerId, the created user, and, for social auth, oauth fields including tokens and the unique OAuth request ID.

onBeforeLogin?​

optional onBeforeLogin?: Reference<AnyFunction>

Called before the user is logged in. Receives providerId and user. Throw from this hook to reject a login based on custom criteria.

onBeforeOAuthRedirect?​

optional onBeforeOAuthRedirect?: Reference<AnyFunction>

Called before redirecting the user to the OAuth provider. Receives the generated url and oauth.uniqueRequestId. Return { url } to override the redirect URL.

onBeforeSignup?​

optional onBeforeSignup?: Reference<AnyFunction>

Called before the user is created. Receives providerId plus the common hook input. Throw from this hook to reject a signup based on custom criteria.


BaseAuthMethodConfig​

Extended by​

Properties​

userSignupFields?​

optional userSignupFields?: Reference<AnyObject>

Object that defines extra fields to save on the user during signup (e.g. firstName, address). Each field name must exist on the configured Auth.userEntity.

Each field function receives the data sent from the client and returns the value Wasp saves to the database. For social auth, this data includes provider-specific profile information. If the value is invalid, throw an error. The password field is excluded from this object and handled by Wasp's auth backend.

See defineUserSignupFields.

Example​
import { defineUserSignupFields } from 'wasp/server/auth'

export const userSignupFields = defineUserSignupFields({
address: (data) => {
if (!data.address) {
throw new Error('Address is required')
}
return data.address
},
phone: (data) => data.phone,
})

BaseSpecElement​

Extended by​

Type Parameters​

Kind​

Kind extends string

Properties​

kind​

kind: Kind

The internal Wasp type of a SpecElement. Used by the compiler. You should not set this field directly, instead use the dedicated constructors.


LocalAuthMethodConfig​

Extends​

Extended by​

Properties​

passwordValidationSchema?​

optional passwordValidationSchema?: Reference<{ _zod: { def: object; }; }>

Zod string schema that new passwords must pass on signup and password reset. Wasp uses its default rules when it's not set.

userSignupFields?​

optional userSignupFields?: Reference<AnyObject>

Object that defines extra fields to save on the user during signup (e.g. firstName, address). Each field name must exist on the configured Auth.userEntity.

Each field function receives the data sent from the client and returns the value Wasp saves to the database. For social auth, this data includes provider-specific profile information. If the value is invalid, throw an error. The password field is excluded from this object and handled by Wasp's auth backend.

See defineUserSignupFields.

Example​
import { defineUserSignupFields } from 'wasp/server/auth'

export const userSignupFields = defineUserSignupFields({
address: (data) => {
if (!data.address) {
throw new Error('Address is required')
}
return data.address
},
phone: (data) => data.phone,
})
Inherited from​

BaseAuthMethodConfig.userSignupFields


AnyFunction​

AnyFunction = (...args) => unknown

Parameters​

args​

...never[]

Returns​

unknown


AnyObject​

AnyObject = Record<PropertyKey, unknown>


Brand​

Brand<B> = object

Type Parameters​

B​

B

Properties​

[___brand]​

[___brand]: B


Branded​

Branded<T, B> = T & Brand<B>

Type Parameters​

T​

T

B​

B


Entities​

Entities = FromRegister<"entities", { }>


FromRegister​

FromRegister<Key, Fallback> = Key extends keyof Register ? Register[Key] : Fallback

Type Parameters​

Key​

Key extends string

Fallback​

Fallback


SocialAuthMethodName​

SocialAuthMethodName = "discord" | "google" | "gitHub" | "keycloak" | "microsoft" | "slack"

Supported social auth providers.