Skip to content

Instantly share code, notes, and snippets.

@puttpotsawee
Created April 30, 2021 11:44
Show Gist options
  • Save puttpotsawee/37b5bfa0ebadecfe24c54a400601ca24 to your computer and use it in GitHub Desktop.
Save puttpotsawee/37b5bfa0ebadecfe24c54a400601ca24 to your computer and use it in GitHub Desktop.
Run-time integration via iframes
<html>
<head>
<title>Feed me!</title>
</head>
<body>
<h1>Welcome to Feed me!</h1>
<iframe id="micro-frontend-container"></iframe>
<script type="text/javascript">
const microFrontendsByRoute = {
'/': 'https://browse.example.com/index.html',
'/order-food': 'https://order.example.com/index.html',
'/user-profile': 'https://profile.example.com/index.html',
};
const iframe = document.getElementById('micro-frontend-container');
iframe.src = microFrontendsByRoute[window.location.pathname];
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment