inertia icon indicating copy to clipboard operation
inertia copied to clipboard

TypeError while accessing Inertia SSR

Open Verox001 opened this issue 7 months ago • 7 comments

Version:

  • @inertiajs/react version: 1.0.14

Describe the problem:

I have setup SSR for my Laravel Vite MUI TSX Application and it's rendering just fine in the browser and I have the feeling that SSR is working, because it's signifitant faster. The problem however is that whenever someones visits the site, I receive following error in the SSR console I started with the Artisan Command:

TypeError: Cannot read properties of undefined (reading 'default')
    at file:///var/www/App/node_modules/@inertiajs/react/dist/index.esm.js:1:1529
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async j (file:///var/www/App/node_modules/@inertiajs/react/dist/index.esm.js:1:1548)

Steps to reproduce:

Just follow the steps from the guide till Hydration: https://inertiajs.com/server-side-rendering

Verox001 avatar Dec 19 '23 17:12 Verox001

I have this too..

boudewijnbout avatar Jan 27 '24 19:01 boudewijnbout

same problem

wkuznet avatar Jan 30 '24 13:01 wkuznet

same problem here

okusarobert avatar Mar 07 '24 23:03 okusarobert

I'm also experiencing the same, and when I disable JS in my browser the page stops working, which indicates SSR is not fully working, I guess... Has anyone solved the issue?

thdebay avatar Mar 26 '24 06:03 thdebay

i'm experiencing the same issue

rockblings avatar Apr 08 '24 05:04 rockblings

I have this one too. It is working locally, but not on Forge.

Same error in Vue.

iambryansanders avatar Apr 08 '24 18:04 iambryansanders

Hi all. You can let us know if you're experiencing the same through a 👍 on the original post. Otherwise please limit the convo to discussing the issue and possible solutions. Thanks

driesvints avatar Apr 08 '24 18:04 driesvints

I don't know exactly what is the problem, but after spending many hours to make inertia ssr actually work with react mui components I found this solution:

in vite.config.js add this:

    ssr: {
        noExternal: [
            "@mui/material",
            "@mui/utils",
            "@mui/base",
            "@mui/icons-material",
            "@mui/system",
            "@mui/styled-engine",
        ],
    },

thanasisxan avatar Apr 16 '24 23:04 thanasisxan

Figured this out with the help of some great people in the discord...

You need to look at the case of the Pages folder. It was capitalized in my app.js, but in my git is was listed was pages.

This is not a bug of SSR itself, but likely how the file is created. Check there first! And then check the case of the components folder too!

iambryansanders avatar Apr 18 '24 13:04 iambryansanders

I think you can close this! @Verox001 @driesvints

iambryansanders avatar Apr 18 '24 13:04 iambryansanders

Thanks!

driesvints avatar Apr 18 '24 13:04 driesvints