If you don't want to use Stackbit's default deployment and hosting methods, you can still work with Stackbit's forms.

Get Environment Variables from Stackbit

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 support@stackbit.com asking for the environment variables to make forms work with your custom deployment. They will look something like this:

  • AWS_LAMBDA_JS_RUNTIME: nodejs14.x
  • STACKBIT_CONTACT_FORM_SUBMISSION_URL: https://api.stackbit.com/project/[PROJECT_ID]/submission-created

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.

Using with Netlify

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:

  1. Go to Settings > Build & deploy > Environment. Add the following environment variables from Stackbit support.
  2. Click Save.
  3. Redeploy the site.

Other Hosting Providers

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.