-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Built-in SSR support #10
Comments
Experimental support here: It's been tested briefly, but I expect to revisit this in a month or two when I'll be dealing with this at work. |
I'm interested in this feature. @MartinMalinda how can I help you build this out? Edit:
|
thanks for reaching out about this There's some WIP on this: https://github.com/MartinMalinda/vue-concurrency/blob/master/src/utils/ssr-utils.ts Maybe it's not the latest WIP.. I think I have some tweaked (better) version that I tested directly in a Nuxt app... I'll try to recover it (tomorrow hopefully 🙏 ). There was some trick with I have no use for this feature currently. I have changed my SSR server -> client strategy. I fully rely on Pinia (pinia is used inside the task). But even with Pinia I had to do some hack to make it work: export function usePiniaPrefetch(cb: () => Promise<any>) {
const root = useRoot() as any;
onServerPrefetch(async () => {
await cb();
const ssrContext = root.context.ssrContext;
ssrContext.nuxt.pinia = getRootState(root.context.req);
});
} I won't have much time to implement this any time soon - but if you play with these things I can definitely do code reviews in a PR and help out a bit 🙏 |
The latest WIP solution worked for me actually. But I remember it broke with Nuxt upgrade. It was quite fragile in a way that it somehow used some Nuxt internal things. Nuxt itself isn't actually doing great job with all the |
Thanks for the quick turnaround @MartinMalinda. I've modified your implementation in |
@kpdemetriou I tried to look it up but couldn't find it, welp. It's in some old branch that I can't identify right now 😬 but I rechecked the implementation and what was important was the usage of PR for the fix for latest Nuxt is welcome 🙏 |
I thought that might be what you meant; relevant PR in #34. |
There's several approaches how to handle SSR with Tasks but none are optimal: https://vue-concurrency.netlify.app/ssr-support/
The approach of saving data to VueX / Pinia or other client side store has proven to work well but probably shouldn't be done just to make SSR with hydration work.
(https://vue-concurrency.netlify.app/examples/store/)
There could be a way to make tasks work with SSR out of the box
_instances
as all other state derives from that._instances
from the ssr context.The text was updated successfully, but these errors were encountered: