Use the Formulate API to build forms using nothing but code.
The code you provide must export a single async function, like so:
export default async function() {
}
You can access API methods/functions using the form
global. This is also aliased to f
and formulate
, so these three calls are equivalent:
await f.short("Hello! What is your name?");
await form.short("Hello! What is your name?");
await formulate.short("Hello! What is your name?");
Answers are collected automatically and persisted when the user has made it to the end of the form. Use the ignore
option to disable answer collection for certain questions.
All API calls that return a Promise
must be await
ed. The Promise
is typically resolved when the user has submitted an answer.
The API provides functions in a few different categories:
And here are a few other related features:
d.ts
definitions for the entire API