pk_test_... or pk_live_...) and a session route on your server.
Install
js.doola.com, which mounts the iframe.
Mount
create()takes no arguments. The iframe shows the wizard, the payment screen or the dashboard depending on the customer’s state.- The element is
<doola-embed>, a full-width block whose height follows its content. - Append it to mount, remove it to unmount. To show a fresh state, such as the founder’s company after payment, replace it with another
doola.create(). Each call creates a separate iframe, so never append a second one beside it.
One instance per page
loadDoola() creates one SDK instance for the page, and its options are fixed by the first call.
- Calling
loadDoola()again with the same publishable key returns the live instance and ignores the new options, callbacks included. React StrictMode’s double invoke is therefore safe. - Calling it with a different key rejects until you call
destroy().
doola.ts
Frameworks
loadDoola() runs in the browser only and rejects on the server, so call it from a client-only path.
- React
- Next.js
- Vue
DoolaFormation.tsx
key.Sign out
Calldestroy() when your user signs out of your product. It ends the doola session and removes every element, and the instance cannot be used again. To embed for the next user, call loadDoola() again.
Never call destroy() on an ordinary unmount or route change. Remove the element instead; the session stays alive for the next mount.
Load faster
Start the connections early with two hints in your<head>:
https://sdk.test.doola.com.
Content Security Policy
If your site sends a CSP, allow the loader and the iframe:https://sdk.test.doola.com in frame-src. If you enforce Trusted Types, allow the doola-js policy. See Security and data.
When it cannot load
loadDoola() rejects when the SDK cannot start, so your page shows its own fallback:
- It ran outside a browser, for example during server rendering.
- The loader script was blocked by a CSP, an ad blocker or the network.
- An option is invalid, such as a key that is not
pk_test_...orpk_live_.... The message names it.
onLoadError to log them, and see Errors for the one case where your page is the only place to tell the founder.