Payload Form Builder Example
This example demonstrates how to implement the official Form Builder Plugin into Payload.
There are various fully working front-ends made explicitly for this example, including:
Follow the instructions in each respective README to get started. If you are setting up the Form Builder for another front-end, please consider contributing to this repo with your own example!
Quick Start
To spin up this example locally, follow these steps:
- Clone this repo
cdinto this directory and runyarnornpm installcp .env.example .envto copy the example environment variablesyarn devornpm run devto start the server and seed the databaseopen http://localhost:8000/adminto access the admin panel- Login with email
demo@payloadcms.comand passworddemo
That's it! Changes made in ./src will be reflected in your app. See the Development section for more details.
How it works
The Form Builder Plugin automatically adds the forms and formSubmissions collections to your config which your front-end can use to query forms and submit form data. You can embed forms into layout building blocks by referring a forms document in a relationship field.
See the official Form Builder Plugin for full details.
Development
To spin up this example locally, follow the Quick Start.
Seed
On boot, a seed script is included to create a user, a home page, and some basic forms.
Production
To run Payload in production, you need to build and serve the Admin panel. To do so, follow these steps:
- First invoke the
payload buildscript by runningyarn buildornpm run buildin your project root. This creates a./builddirectory with a production-ready admin bundle. - Then run
yarn serveornpm run serveto run Node in production and serve Payload from the./builddirectory.
Deployment
The easiest way to deploy your project is to use Payload Cloud, a one-click hosting solution to deploy production-ready instances of your Payload apps directly from your GitHub repo. You can also deploy your app manually, check out the deployment documentation for full details.
Questions
If you have any issues or questions, reach out to us on Discord or start a GitHub discussion.