Is there a way to get the Javascript SDK through a CDN? I can't install it through NPM so I need another way to get it. I need to use postMessage from an embed to send some data to Retool through an embed and having some issues
Hi @Daniel_Ramalhosa1, Welcome to the Retool Community!
1. Load the Retool SDK
Since NPM installation isn’t an option, you can use the Retool SDK via CDN:
<script src="https://cdn.retool.com/embed.js"></script>
This makes window.Retool
available in your JavaScript for communication with Retool.
2. Sending Data to Retool from the Embed
Use window.Retool.sendData()
to send data from your embedded page to Retool:
window.Retool.sendData({
message: "Hello from Embed!",
userId: 12345
});
In Retool, capture this data using an Event Handler.
3. Receiving Data from Retool in the Embed
To receive updates from Retool in your embed, subscribe to changes:
window.Retool.subscribe((model) => {
console.log("Data received from Retool:", model);
});
This triggers whenever the embed model updates.
4. Using postMessage
for Custom Communication
If embedding Retool inside another app, postMessage
allows communication between the iframe and its parent:
window.parent.postMessage({ type: "customEvent", data: { key: "value" } }, "*");
For more details, check the documentation:
Embed Apps in Retool
Feel free to ask if you need more help—we’re here to assist!
Sorry I think I worded my post wrong. I have a page and in it I have an iframe of my retool page. How do I send data from my page to the retool portal that is embedded?