Webhooks

See deployments and automation for high-level information about how and when to use webhooks.

Overview

Plasmic can automatically call webhooks when an editor publishes a project. You can use webhooks for a wide variety of automation use cases, such as publishing directly to production.

Webhook configuration

The webhooks publish action can trigger any number of webhooks. Each webhook can be configured in the following ways:

  • HTTP method
  • URL
  • Headers (optional)
  • Payload (optional)
Publishing custom webhooks

Advanced

Deploying without publishing

When an editor publishes a project, Plasmic defaults to saving a new version and triggers all publish actions (typically deploying to production). But sometimes you need to test something in a production-like environment without actually deploying it. Here’s one way to set this up:

  1. In your code, make the staging environment render the preview of your project. For instance, if you use an environment variable DEPLOY_ENVIRONMENT=staging:
    Copy
    const PLASMIC = initPlasmicLoader({
    projects: [
    /*...*/
    ],
    preview: process.env.DEPLOY_ENVIRONMENT === 'staging'
    });
  2. Add a webhook (separate from the existing webhook that triggers production) to trigger a staging environment build.

From now on, editors can publish to staging like this:

  1. Click the top-right “Publish” button to open the publish dialog.
  2. Uncheck the “Save a version” checkbox. This prevents any subsequent production builds from accidentally fetching the latest changes.
  3. Check only the webhook for publishing to staging.
  4. Click “Publish”.
Was this page helpful?

Have feedback on this page? Let us know on our forum.