If you don't want to use Stackbit's default deployment and hosting methods, you can still work with Stackbit's forms.
The first thing you'll need to make it all work is a secret that we generate for your site. This is currently retrieved manually.
Send a message to email@example.com asking for the environment variables to make forms work with your custom deployment. They will look something like this:
Note here that
[SECRET] is the secret you received from Stackbit support and
[PROJECT_ID] is the ID of your project in Stackbit, which you can get from the URL in Stackbit.
Because Stackbit deploys to Netlify by default, getting our form submission to work with Netlify is the easiest solution.
Open your project in Netlify, and follow these steps:
- Go to Settings > Build & deploy > Environment. Add the following environment variables from Stackbit support.
- Click Save.
- Redeploy the site.
If using another hosting provider, the steps will look similar to Netlify. However, the default submission function won't work by default.
First, follow these steps to add a custom form submission function as an API route. Copy the contents of
.netlify/functions/submission_created.js to this file.
Then set the environment variables received from Stackbit support. This process will differ depending on the hosting provider you're using. Most services require that you redeploy your site after changing environment variables.