On Mintlify, add a .js file to your content directory that injects the AppAdSwap script, and put the slot in your MDX pages. Mintlify includes every .js file in the content directory on every page, with no extra wiring.
Before you start
Mintlify's documentation says custom JavaScript is the equivalent of adding a script tag to every page, so it's global: you can't scope it to specific pages, and it carries the warning to use it with caution. It doesn't state which plan includes the feature, so check your plan before you start. Don't put secrets in the file; it's readable in the browser.
Step 1: add the JavaScript file
The content directory is the folder that holds your docs.json and your MDX pages. Create a file there, for example appadswap.js:
// appadswap.js
const script = document.createElement("script")
script.src = "https://appadswap.com/w.js"
script.async = true
document.head.appendChild(script)
Mintlify advises injecting a <script> element from your JavaScript file rather than writing a raw <script src="..."> tag in MDX, which is what this does. You don't import the file from docs.json or from any page; Mintlify finds it. Scripts run after the page becomes interactive, and with more than one .js file there is no guaranteed order, so keep this one self-contained.
Step 2: add the slot to a page
In any MDX page, add the slot as a self-closing element:
## Questions?
<div data-appadswap="SITE_ID" data-format="card" />
Moving between pages
Mintlify's scripts run once per visit, not on each navigation; its documentation suggests listening for the mintlify:navigate event on window if your code has to run again. You don't need to for this: the widget watches for new slots and fills any that appear after it has loaded, so a slot on a page you navigate to still fills.
Corner card, no slot
To use the corner format, set the attributes on the injected script and skip the slot:
const script = document.createElement("script")
script.src = "https://appadswap.com/w.js"
script.async = true
script.setAttribute("data-appadswap", "SITE_ID")
script.setAttribute("data-format", "corner")
document.head.appendChild(script)
Check it works
Run mint dev to preview locally, or deploy, then open a page with a slot. The Sites page in your dashboard flips from unverified to live on its own once the widget has loaded on the address you registered, so the deployed docs are the real check.
If it doesn't work
- No request for
w.js. The file isn't inside the content directory, or isn't named with a.jsending. It has to sit besidedocs.json, or under it. - The card shows on every page you didn't want. The corner format and a script in a global file apply everywhere. Use slots, which only appear where you place them.
- The slot is empty. The script hasn't loaded yet or is blocked. Check the Network tab.
Source
Mintlify's custom scripts page. Next: other install guides, or add your app.