> Add Plandalf to any site you edit by hand: one script tag, then a data attribute on any button or element.

Source: https://plandalf.com/docs/frameworks/html

Frameworks

# HTML

On a site you edit by hand, Plandalf is one script tag and one attribute. Use this page for static sites, site generators and any platform that lets you paste HTML.

## Add the script

These are the steps your checkout's **Share** screen shows for HTML. Copy the snippets from there and they already hold your script address and checkout slug.

1.  ### Install the SDK
    
    Place the script tag right before </body> on every page that needs the checkout. The SDK is async — it won't block page render.
    
    ```html
    <script async src="https://YOUR-ORG.plandalf.dev/js/plandalf-sdk.js"></script>
    ```
    
2.  ### Add the trigger button
    
    Drop this on any clickable element — button, link, div, whatever. The SDK auto-binds the click on load (and via MutationObserver for elements added later).
    
    ```html
    <button data-plandalf-present="YOUR-CHECKOUT">Buy Now</button>
    ```
    
3.  ### Make the first open instant (optional)
    
    Paste this under the SDK script tag on the pages that hold the trigger. It fetches the checkout UI (about 1.2 MB) in the background while the page sits idle, so the click only pays for creating the session. Leave it off pages with no checkout: visitors download it whether or not they buy. In a React app, call sdk.preload('checkout') from the ready callback in an effect instead.
    
    ```html
    <script>
      // Optional: fetch the checkout UI while the page is idle, so the first click opens at once.
      window.plandalf = window.plandalf || function () { (window.plandalf.q = window.plandalf.q || []).push(arguments); };
      plandalf('ready', (sdk) => sdk.preload('checkout'));
    </script>
    ```
    

**Tip**

Programmatic alternative: plandalf.present('YOUR-CHECKOUT').

[![The Share screen's Install steps with HTML picked: the script tag, where it goes before the closing body tag, and the trigger button](https://plandalf.com/docs/shots/platforms/share-html.webp)](https://plandalf.com/docs/shots/platforms/share-html.webp)

Pick HTML on your checkout's Share screen to get these steps with your own script and checkout slug.

A full page looks like this:

```html
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Pricing</title>
  </head>
  <body>
    <button data-plandalf-present="YOUR-CHECKOUT">Buy Now</button>

    <script async src="https://YOUR-ORG.plandalf.dev/js/plandalf-sdk.js"></script>
  </body>
</html>
```

## Open a checkout from a button

Add `data-plandalf-present` to any button, link or other element, with your checkout's slug as the value:

```html
<button data-plandalf-present="YOUR-CHECKOUT">Buy Now</button>
```

Choose how it opens with `data-plandalf-frame` (`modal`, `slideout`, `bottom` or `fullscreen`) and, for a modal, its width with `data-plandalf-size`. See [Buy buttons](https://plandalf.com/docs/checkouts/buy-buttons).

### From your own code

Call `plandalf.present()` from a click handler. It returns a handle you can await for the result:

```js
// Open the checkout from your own click handler
const flow = plandalf.present('YOUR-CHECKOUT');

// flow is a Promise, plus .events (async-iterable) and .close()
const result = await flow;
if (result.status === 'complete') router.push('/thanks');

// Or watch it live instead of awaiting the end:
// for await (const event of flow.events) console.log(event.type);
```

To call it before the script has loaded, add the queue stub first, and use `plandalf('ready', …)`:

```html
<script>
  window.plandalf = window.plandalf || function () { (window.plandalf.q = window.plandalf.q || []).push(arguments); };
  plandalf('ready', (sdk) => {
    document.querySelector('#upgrade').addEventListener('click', () => sdk.present('YOUR-CHECKOUT'));
  });
</script>
```

There is more in [Open a checkout from code](https://plandalf.com/docs/developers/open-a-checkout).

## Show a checkout on the page

Add `data-plandalf-mount` to an empty element. The checkout renders inside it when the page loads:

```html
<div data-plandalf-mount="YOUR-CHECKOUT" style="min-height: 480px"></div>
```

Or mount it from code into any container:

```js
// Mount the checkout inline into your own container
const flow = plandalf.mount('#checkout', 'YOUR-CHECKOUT');

// Inline checkouts don't resolve on completion — listen instead:
for await (const event of flow.events) {
  if (event.type === 'complete') router.push('/thanks');
}
```

## Show a deadline timer

Add an empty element with your deadline timer's slug. The script draws the live countdown inside it. To charge the deadline timer's current price, add `data-plandalf-apply-promo` with the same slug to your buy button.

```html
<div data-plandalf-promo="YOUR-PROMO"></div>
<button data-plandalf-present="YOUR-CHECKOUT" data-plandalf-apply-promo="YOUR-PROMO">Buy Now</button>
```

Add `data-plandalf-hide-on-expire` to the countdown element to hide it when the countdown ends. See [Countdowns](https://plandalf.com/docs/promos/countdowns).

## From a bundler

If you bundle your JavaScript, install the SDK and connect your buy button to it in your entry file.

```bash
npm install @plandalf/sdk
```

```html
<button id="buy">Buy Now</button>
```

```js
import { Plandalf } from '@plandalf/sdk';

const checkout = new Plandalf({ apiBase: 'https://YOUR-ORG.plandalf.dev' });
document.querySelector('#buy').addEventListener('click', () => {
  checkout.present('YOUR-CHECKOUT');
});
```

## Check it's working

1.  ### Open the page
    
    If you used the hosted script, type `typeof window.plandalf` in the browser console. Look for `"function"`.
    
2.  ### Click your button
    
    Plandalf should display your checkout over the page.
    
3.  ### Make a test purchase
    
    Add `localhost` and your staging site in Plandalf under **Settings → Advanced → Test domains**. Checkouts there use Stripe test cards. See [Test mode](https://plandalf.com/docs/get-started/test-mode).
    

## If it isn't working

-   If your site sends a Content Security Policy, allow `https://*.plandalf.dev` and `https://js.stripe.com` in `script-src`, `connect-src` and `frame-src`.
-   Add `data-debug="true"` to the script tag and the console logs each step the script takes.

See [Troubleshooting](https://plandalf.com/docs/help/troubleshooting).

Something wrong or missing? Email [hello@plandalf.com](mailto:hello@plandalf.com).
