Checkout embed

Next.js + Klaviyo integration

Your Next.js app owns the page, Plandalf owns checkout, and the paid order lands in Klaviyo as an event that can start a flow.

No credit card required. No coding required.

Does Next.js integrate with Klaviyo?

Plandalf has no native Klaviyo steps. A Next.js client component opens the checkout; after payment a Send Webhook step can post to Klaviyo's events API directly or to a route handler in your app. Klaviyo flows can also post to a Plandalf catch URL to enrol a profile in a promo.

What moves between Next.js and Klaviyo

EventFrom and toThroughWhat happens
Checkout openedNext.jsPlandalfCheckout embedThe provider loads the SDK with next/script, and a client component renders data-plandalf-present after the SDK is ready.
Checkout completedPlandalfKlaviyoWebhookSend Webhook calls your route handler, which creates the event on Klaviyo's /api/events endpoint with a metric name, the profile's email, properties and a numeric value.
Profile updatePlandalfKlaviyoWebhookThe same handler can call the profile import endpoint, which creates a profile (201) or updates an existing one (200).
Flow webhookKlaviyoPlandalfWebhookA flow webhook action posts to a Plandalf Webhook Trigger URL, and Enroll in Promo gives that profile a countdown.
Countdown inside a flow emailPlandalfKlaviyoBy handThe Plandalf countdown image tag goes into an HTML block, with Klaviyo's person email merge tag as the ref.

Turn a Next.js purchase into a Klaviyo event

A route handler keeps the Klaviyo private key on the server and gives you somewhere to shape the body Klaviyo expects.

  1. Add the provider and a client button

    Wrap the root layout's children in a client provider that loads the Plandalf script with next/script. Render the checkout button only after the SDK's ready callback has fired, so server rendering never touches window.

  2. Sign identity for logged-in users

    If buyers have accounts, sign a Plandalf customer JWT on your server with sub, email and name, and pass it with plandalf.identify(token) before opening checkout. Keep the signing key off the client.

  3. Create a Klaviyo private key

    Make a key with the events write scope, and the profiles write scope if you will also import profiles. Put it in a server-only environment variable.

  4. Write the route handler

    Accept a POST with a shared secret header, then call Klaviyo's create event endpoint with the revision header, a metric named Plandalf Purchase, the email, a properties object and the amount as value. Return quickly, since Klaviyo answers 202 for queued events.

  5. Send the webhook from Plandalf

    Start a sequence on Checkout Completed, add Send Webhook to your handler's URL with the secret in Headers, and a JSON payload using {{trigger.customer_email}}, {{trigger.total_amount}} and {{trigger.invoice_number}}.

  6. Build the Klaviyo flow

    In Klaviyo make a flow triggered by the Plandalf Purchase metric. Test with a Stripe test card and Run on test purchases switched on.

What sellers do with Next.js and Klaviyo

Ecommerce-style Next.js storefronts

A small brand with a custom Next.js catalogue sells through Plandalf's checkout. The purchase event drives a post-purchase flow and a replenishment reminder.

Product-led SaaS with upgrade prompts

An app opens the checkout from an upgrade button with the user's JWT. The event lets Klaviyo separate upgraded accounts from free ones in campaigns.

Limits and gotchas

  • Klaviyo's events API answers 202, which only means the event was queued. Check the Klaviyo profile's activity before assuming a flow ran.
  • Klaviyo describes flow webhooks as one-way and requires multi-factor authentication and a Manager, Admin or Owner role to add one.
  • Send Webhook has a 30 second reply window and no signature. Verify the secret header and dedupe by invoice number in your handler.
  • Unreleased SDK repairs are noted in the Next.js guide for cleanup and countdown ownership, so test route changes against your deployed script.
  • A refund does not remove anything in Klaviyo by itself. Add a sequence on Invoice Refunded that posts a refund event if flows should react.

Next.js and Klaviyo: common questions

Does Next.js integrate with Klaviyo?
Plandalf has no Klaviyo connector. Your Next.js app opens the Plandalf checkout, and after payment a Send Webhook step or a route handler of yours sends the purchase to Klaviyo's API.
How do I send Plandalf purchases to Klaviyo from Next.js?
Build a Checkout Completed sequence with Send Webhook pointing at a route handler, and have the handler call Klaviyo's create event endpoint with your private key and a metric name.
Can I skip the route handler?
You can call Klaviyo directly from Send Webhook if it can send the headers and content type Klaviyo requires. A handler gives you control over the body, and Zapier's Webhooks are the other relay.

Feature detail