Home > Enterprise >  Nuxt - How to hydrate app.js in PHP page canvas?
Nuxt - How to hydrate app.js in PHP page canvas?

Time:11-10

I need to handle one part of the webpage's canvas in PHP and another one in Nuxt. So in my php page I have set this structure.

<!-- Some php code -->
<div id="app">
  <!--I have to Inject Nuxt -->
</div>
<!-- Some php code -->

I can do it with Vue. In the header of my PHP file I load the script http://localhost:8080/js/app.js and the app Div is hydrated.

How can I do it in Nuxt ?

Do you know where are generated the nuxt files (with hot-module-replacement or with the build) ?

Thanks,

CodePudding user response:

You will not be able to plug Nuxt like Vue with a simple querySelector, because Nuxt requires a decent amount of build step. It's not as flexible as Vue because it is one solution in itself to SSR your whole project.

Best idea would be to either continue to use Vue during your migration, when all is done: upgrade Vue to Nuxt (not that hard if your code is already following some conventions, other just look how it is organized in Nuxt).

Create a standalone Nuxt app, next to your PHP website and start making HTTP calls to your headless CMS without breaking anything.

Don't waste time trying to setup some weird behavior of them running at the same time, you will lose more time IMO.

  • Related