Turn your web-app into a cross-domain component with five lines of code

This article is part of a series on PayPal’s Cross-Domain Javascript Suite.

I’ve just published v2 of zoid:

With the latest version, it’s even easier to turn any web-app (or web-component) into a cross domain component. You just create a component, give it a name, and point it to the url where your app will be rendered:

Now, all you need to do is include the zoid definition you just created, and accept some props from window.xprops, inside the page which your url renders:

And you’re done! Anyone wanting to render your page can now do so, and pass down props directly from their page into the iframe-component:

This is a great way of sharing functionality from your site, to another site.

Hope this is useful. This example was just vanilla javascript, but it works great with libraries like React too!

Thanks all!

works for PayPal, as a lead engineer in Checkout. Opinions expressed herein belong to him and not his employer. daniel@bluesuncorp.co.uk

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store