[Vuejs]-Can you get Heroku to use different code depending on mobile/web?

0👍

You can dynamically create script tag with src set to correct app bundle (either react, either vue):

<script type="text/javascript">
  const appScript = document.createElement('script');
  if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
    // Mobile, put path to vue.js app bundle
    appScript.setAttribute('src','path/to/vue/app/bundle');
  } else {
    // Desktop, put path to react.js app bundle
    appScript.setAttribute('src','path/to/react/app/bundle');
  }
  document.head.appendChild(appScript);
</script>

Note: this answer is combined from those two:

Create script on fly

Detecet a mobile device

Leave a comment