--- title: Wasp Language (.wasp) --- Wasp language (what you write in .wasp files) is a declarative, statically typed, domain-specific language (DSL). It is a quite simple language, closer to JSON, CSS or SQL than to e.g. Javascript or Python, since it is not a general programming language, but more of a configuration language. It is pretty intuitive to learn (there isn't much to learn really!) and you can probably do just fine without reading this page and learning from the rest of the docs as you go, but if you want a bit more formal definition and deeper understanding of how it works, then read on! ## Declarations The central point of Wasp language are **declarations**, and Wasp code is at the end just a bunch of declarations, each of them describing a part of your web app. ```wasp app MyApp { title: "My app" } route RootRoute { path: "/", to: DashboardPage } page DashboardPage { component: import Dashboard from "@client/Dashboard.js" } ``` In the example above we described a web app via three declarations: `app MyApp { ... }`, `route RootRoute { ... }` and `page DashboardPage { ... }`. Syntax for writing a declaration is ` `, where: - `` is one of the declaration types offered by Wasp (`app`, `route`, ...) - `` is an identifier chosen by you to name this specific declaration - `` is the value/definition of the declaration itself, which has to match the specific declaration body type expected by the chosen declaration type. So, for `app` declaration above, we have: - declaration type `app` - declaration name `MyApp` (we could have used any other identifier, like `foobar`, `foo_bar`, or `hi3Ho`) - declaration body `{ title: "My app" }`, which is a dictionary with field `title` that has string value. Type of this dictionary is in line with the declaration body type of the `app` declaration type. If we provided something else, e.g. changed `title` to `little`, we would get a type error from Wasp compiler since that does not match the expected type of the declaration body for `app`. Each declaration has a meaning behind it that describes how your web app should behave and function. All the other types in Wasp language (primitive types (`string`, `number`), composite types (`dict`, `list`), enum types (`DbSystem`), ...) are used to define the declaration bodies. ## Complete List of Wasp Types Wasp's type system can be divided into two main categories of types: **fundamental types** and **domain types**. While fundamental types are here to be basic building blocks of a a language, and are very similar to what you would see in other popular languages, domain types are what makes Wasp special, as they model the concepts of a web app like `page`, `route` and similar. - Fundamental types ([source of truth](https://github.com/wasp-lang/wasp/blob/main/waspc/src/Wasp/Analyzer/Type.hs)) - Primitive types - **string** (`"foo"`, `"they said: \"hi\""`) - **bool** (`true`, `false`) - **number** (`12`, `14.5`) - **declaration reference** (name of existing declaration: `TaskPage`, `updateTask`) - **ServerImport** (external server import) (`import Foo from "@server/bar.js"`, `import { Smth } from "@server/a/b.js"`) - The path has to start with "@server". The rest is relative to the `src/server` directory. - import has to be a default import `import Foo` or a single named import `import { Foo }`. - **ClientImport** (external client import) (`import Foo from "@client/bar.js"`, `import { Smth } from "@client/a/b.js"`) - The path has to start with "@client". The rest is relative to the `src/client` directory. - import has to be a default import `import Foo` or a single named import `import { Foo }`. - **json** (`{=json { a: 5, b: ["hi"] } json=}`) - **psl** (Prisma Schema Language) (`{=psl psl=}`) - Check [Prisma docs](https://www.prisma.io/docs/concepts/components/prisma-schema/data-model) for the syntax of psl data model. - Composite types - **dict** (dictionary) (`{ a: 5, b: "foo" }`) - **list** (`[1, 2, 3]`) - **tuple** (`(1, "bar")`, `(2, 4, true)`) - Tuples can be of size 2, 3 and 4. - Domain types ([source of truth](https://github.com/wasp-lang/wasp/blob/main/waspc/src/Wasp/Analyzer/StdTypeDefinitions.hs)) - Declaration types - **action** - **api** - **apiNamespace** - **app** - **entity** - **job** - **page** - **query** - **route** - **crud** - Enum types - **DbSystem** - **HttpMethod** - **JobExecutor** - **EmailProvider** You can find more details about each of the domain types, both regarding their body types and what they mean, in the corresponding doc pages covering their features.