veliovgroup / flow-router

🚦 Carefully extended flow-router for Meteor
https://packosphere.com/ostrio/flow-router-extra
BSD 3-Clause "New" or "Revised" License
201 stars 30 forks source link

Svelte support? #101

Closed tosinek closed 1 year ago

tosinek commented 1 year ago

Hi, I cannot figure out how this package could work with Svelte. The React example includes a special mounter import { mount } from 'react-mounter'; but I cannot find anything like that for Svelte. My goal is to make SSR work (for Svelte) so I am testing various routers. It looks like the only way to include Svelte is if it is wrapped inside a Blaze component. But that is quite complicated to work with imo. Thank you.

dr-dimitru commented 1 year ago

@tosinek thanks for the question, generally it should work with any templating library. Just place your render function inside of action(){} method

tosinek commented 1 year ago

I don't think there is such a function in Svelte. There is Component.render(), but that is only available on the server and the components are rendered by its HTML tag <MyComponent /> - so I guess it must be a compiler abstracting it out? Including it using plain DOM JS doesn't seem to work either.

dr-dimitru commented 1 year ago

@tosinek https://github.com/meteor-svelte/meteor-svelte :

By default, Svelte removes server-rendered static HTML when the application is loaded on the client and replaces it with a client-rendered version.

And I think you don't need FlowRouter for Svelte — https://forums.meteor.com/t/recommended-router/53670/8

Feel free to close it in case if the issue is solved on your end.

tosinek commented 1 year ago

I was quite desperate, so I included flow-router as it says "supports Svelte" and is the only Meteor-first solution. There is too many gotchas along the way, tinro doesn't work for SSR (too many references to browser methods in the code to start with) but I just managed to make svelte-routing work with SSR. I will try to get back to other solutions too.

I am closing this, and you may consider removing "supports Svelte" from the docs :). Thank you for your time and replies!

dr-dimitru commented 1 year ago

@tosinek library supports front-end svelte, perhaps you are implementing SSR version

tosinek commented 1 year ago

It is the same Svelte for both client and server. I tried to integrate client only with flow-router, but except for wrapping it in a Blaze component, I could not figure it out.