DatoCmsPlugin.init() callback doesn't get fired

Hi Dato,

I wrote a simple plugin long time ago to display a custom button for our preview feature. Recently It has stopped working and I don’t know why since It has been working for a long time before. Not sure if you guys changed any thing on the API?

Basically, the function call on the init function has never been called. Seems like the promise has neer been resolve. Any idea?

See the gif for more detail.

DatoCmsPlugin.init(function(plugin) {

  const getButton = () => document.getElementById("previewButton")
  const setButtonUrl = (button, url) => button.setAttribute("href", url)
  const setButtonText = (button, text) => button.textContent = text
  const setButtonVisible = (button) => button.style.visibility = "visible"

  const init = () => {
    var label = plugin.parameters.instance.label;
    //blog or caseStudy
    var dataSource = plugin.parameters.instance.previewType || "blog";
    let slug = plugin.getFieldValue("slug");
    let url = `source=${dataSource}&slug=${slug}`;

    var button = getButton();
    setButtonText(button, label);
    setButtonUrl(button, 'https://www.nugit.co/blog-preview/?' + url);

  const initPlugin = () => {


And this the HTML, I took it from the template.

<!DOCTYPE html>
<html lang="en">

  <meta charset="utf-8" />
  <link href="https://unpkg.com/datocms-plugins-sdk/dist/sdk.css" media="all" rel="stylesheet" />
  <script src="https://unpkg.com/datocms-plugins-sdk"></script>
  <script src="preview.js"></script>
  <style type="text/css">
      .fullwidth-button {
        width: 100%;
        text-align: center;

  <a id="previewButton" class="DatoCMS-button--primary fullwidth-button" target="_blank" style="visibility:hidden"></a>


hello @chosenlab.dev and welcome to Community :slight_smile:

Not sure what’s wrong, I’ve just tried myself with your code and works as expected. If you want to share with me your project I can give it a try. Send me the URL of your project as a private message or via the support form: https://www.datocms.com/support/

I submitted my plugin URL through https://www.datocms.com/support/. Please take a look. Thanks for your support.