eidellev / inertiajs-adonisjs

279 stars 17 forks source link

Is it possible to use the SSR feature programatically? #60

Closed dmostafiz closed 2 years ago

dmostafiz commented 2 years ago

I am sorry to opening this as an issue! but its really important to have the SSR feature as optional for some pages. like some pages is not require SSR. On the other hand very few pages are required to Render on server side for SEO. I hope you understand my question.

So if its possible to enable SSR mode only to some certain pages please share how to do it. i tried by getting the route url by accessing CTX from the const ctx = HttpContext.get() but failed.

eidellev commented 2 years ago

Hi @dmostafiz Thank you for opening this issue. I think this makes sense as a feature request. Maybe I can make the following change to the inertia API:

return inertia.render('Tasks/IndexPage', props, { ssr: false });

does this make sense to your use case?

dmostafiz commented 2 years ago

That will be a great job. its same like NextJs dynamic imports.

dmostafiz commented 2 years ago

perhaps it will be more better to {ssr: true} instead of {ssr: false}. its the reverse case. if any page require to render in serverside at that time we can send as {ssr: true}. and by default ssr will be false. what you think about that??

dmostafiz commented 2 years ago

And another thing, what if we need to import an library which is only for client side rendering... for example a library has document or window like things that are undefined on server. and we need to import that plugin on a SSR page... i its very important to thing in the case of SSR+SPA.

recently i faced an issue on that. i enabled SSR in inertia config file. In a react page i imported a libray which is very important for my project. its running perfectly client side. but when i am reloading the window manually its througing window not defined error.

eidellev commented 2 years ago

Thanks for the feedback. I want to make something that will be useful to as many other developers as possible, so this is important.

eidellev commented 2 years ago

@dmostafiz sorry for the long wait implemented in v7.1.0

dmostafiz commented 2 years ago

Wow... Thanks