### What? Migrates the `form-builder` example to payload `3.0`. `Updates`: - Now has a next app directly along side payload. - Removes `form-builder/next-app` & `form-builder/next-pages` example front-ends and only uses new recommended approach (i.e admin panel & front-end on the same port - `3000`)
Payload Form Builder Example
The Payload Form Builder Example demonstrates how to implement the official Form Builder Plugin in Payload.
IMPORTANT—This example includes a fully integrated Next.js App Router front-end that runs on the same server as Payload.
Quick Start
-
Clone this repo
-
cdinto this directory and runpnpm i --ignore-workspace*,yarn, ornpm install*If you are running using pnpm within the Payload Monorepo, the
--ignore-workspaceflag is needed so that pnpm generates a lockfile in this example's directory despite the fact that one exists in root. -
cp .env.example .envto copy the example environment variables -
pnpm dev,yarn devornpm run devto start the server- Press
ywhen prompted to seed the database
- Press
-
open http://localhost:3000to access the home page -
open http://localhost:3000/adminto access the admin panel- Login with email
demo@payloadcms.comand passworddemo
- Login with email
That's it! Changes made in ./src will be
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 scaffold a basic database for you to use as an example. You can remove pnpm seed from the dev script in the package.json to prevent this behavior. You can also freshly seed your project at any time by running pnpm seed. This seed creates a user with email demo@payloadcms.com and password demo along with a home page and an example page with two versions, one published and the other draft.
NOTICE: seeding the database is destructive because it drops your current database to populate a fresh one from the seed template. Only run this command if you are starting a new project or can afford to lose your current data.
Production
To run Payload in production, you need to build and serve the Admin panel. To do so, follow these steps:
- Invoke the
next buildscript by runningpnpm buildornpm run buildin your project root. This creates a.nextdirectory with a production-ready admin bundle. - Finally run
pnpm startornpm run startto 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 choose to self-host your app, check out the Deployment docs for more details.
Questions
If you have any issues or questions, reach out to us on Discord or start a GitHub discussion.