Integration with Cargo-Leptos
Kade-Powell opened this issue ยท 6 comments
Hello, I was wondering if there was any plans to get this library working with cargo-leptos? I was looking to make a template for The axum template with leptonic. What work is needed to make that happen? i'd be willing to help out on that feature if given some context.
I added initial SSR support in the main branch. Would you like to check out the current state?
I also need to use SSR support with cargo leptos support without trunk, are there any instructions in the documentation? I can't find anything about it. I use Actix-Web instead of Axum, but I think that should be the least of the problems
@ccmvn Have you figured it out by any chance?
Unfortunately not, I also wrote an email to the repo owner but no answer came back
@ccmvn Have you figured it out by any chance?
Unfortunately not, I also wrote an email to the repo owner but no answer came back
Thank you for coming back.
After I asked here and was not able to make Leptonic work, we switched to Thaw, which got better documentation regarding the SSR thing, and I actually made it work. After many hours spent reading Leptos and Thaw docs, I actually understood the whole thing, and I made Leptonic work with cargo leptos
in a matter of 30 minutes. I made a public repo template that you can check https://github.com/dady8889/leptos-ssr-leptonic.
Explanation if anyone stumbles here and is lost like me.
- Cargo leptos builds your project as
lib
once withfeatures = ssr
and once withfeatures = hydrate
by default. - With
features = hydrate
, the WASM library gets compiled, but withfeatures = ssr
, only the server's stuff gets compiled - Therefore, when you try to run a frontend component like
<Button>
in a code that gets compiled withfeatures = ssr
, you get an error. - To make this work, library maintainers must provide also a crate with "features = ssr/hydrate" that you can conditionally compile, and in the SSR mode, you basically do nothing, its just an empty function.
For Thaw, that was all I needed to do. But for Leptonic, there was also a few more things, and you can see everything in this commit: dady8889/leptos-ssr-leptonic@36e8725
Can confirm this appears to work.