Skip to content

Incompatibility with Inertia SSR Server #5254

@miguilimzero

Description

@miguilimzero

Is this bug related to Nuxt or Vue?

Vue (Inertia in particular)

Package

v4.x

Version

v4.0.1

Reproduction

The UI library is currently incompatible with the Inertia SSR server: https://inertiajs.com/server-side-rendering.

The compiled SSR file tries to alter the document.head which is not possible in SSR:

  if (nuxtApp.isHydrating && !nuxtApp.payload.serverRendered) {
    const style = document.createElement("style");
    style.innerHTML = root.value;
    style.setAttribute("data-nuxt-ui-colors", "");
    document.head.appendChild(style);
    headData.script = [{
      innerHTML: "document.head.removeChild(document.querySelector('[data-nuxt-ui-colors]'))"
    }];
  }

It is currently trying to do that as the payload.serverRendered is set to false in the useNuxtApp() function in the compiled file:

 function useNuxtApp() {
  return {
    isHydrating: true,
    payload: { serverRendered: false },
    hooks,
    hook: hooks.hook
  };
}

Changing the value manually to true seems to fix the issue, so I believe it is just a matter of detecting if it is being compiled to Inertia SSR or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageAwaiting initial review and prioritizationv4#4488

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions