javascriptcssmeteorswup

Initialize and use Swup in Meteor js


I am trying to use swup in meteor js framework. I added the script tag that contains unpkg link for swup in main.html and initialized Swup in Meteor.startup function of main.js. But when i run the app, it is throwing "Cannot set property 'responseURL' of null" error.

in main.html:

<script src="unpkg.com/swup@latest/dist/swup.min.js"></script>  
<script>
    const swup = new Swup();
</script>

And added swup id to layout.html which is like the container in which all routing occurs.

I just recently started to work on Meteor, so i am a bit confused. I would be glad, if anyone could help me in initializing and setting up swup. Thanks in Advance.


Solution

  • Blaze strips any script tag including it's content to prevent XSS. Install swup via npm and import it in your Template to resolve this:

    $ meteor npm install --save swup
    

    and in your client/main.js you initialize swup:

    import Swup from 'swup';
    const swup = new Swup();