leptos-rs / start-actix

Starter template for use with the Leptos web framework.
The Unlicense
122 stars 31 forks source link

Add optional `ssg` feature to template #21

Closed ActuallyHappening closed 1 year ago

ActuallyHappening commented 1 year ago

I want to use an external tool Tauri along with Leptos, and find it necessary to use trunk serve and trunk build for this purpose. However, I had to manually add the logic on top of the starter template, which explicitly said: no client-side main function unless we want this to work with Trunk.

I believe that adding this feature will be helpful to those who are trying to mix cargo Leptos serve and trunk serve together

gbj commented 1 year ago

Are you just saying that you want to be able to run the same app either hosting on a server with server-side rendering or in Tauri with client-side rendering, and use the same template?

Or do you only want to use it with client-side rendering with Tauri?

If it's just client-side rendering, I'd suggest that creating a client-side-only template is a better idea, except that setting Leptos up with Trunk is so straightforward we haven't created a template yet.

If it's to switch between client-side rendering and server-side rendering, then I'd suggest using csr instead of ssg. What the ssg feature does here is not static site generation and could be confusing for people.

ActuallyHappening commented 1 year ago

Well, the only way to produce a static site integrating Leptos is with the csr feature. If changing the PR's feature name to csr instead of the current ssg helps other understand how to make a static site as well as a ssr app with Leptos I'll change it

gbj commented 1 year ago

I'm still curious about the answer to the main question though:

Are you just saying that you want to be able to run the same app either hosting on a server with server-side rendering or in Tauri with client-side rendering, and use the same template?

Or do you only want to use it with client-side rendering with Tauri?

If it's just client-side rendering, I'd suggest that creating a client-side-only template is a better idea, except that setting Leptos up with Trunk is so straightforward we haven't created a template yet.

If you don't want the server side at all, I think creating a separate template that doesn't have the unneeded complexity is a better idea.

ActuallyHappening commented 1 year ago

For context, I am using Tauri and leptos to create a cross-platform app + ssr website. I don't strictly need the ssr feature but I wanted to see if it was possible. Template for such a project: https://github.com/ActuallyHappening/start-leptos-tauri When I cloned the official leptos starter project and read the comments 'no client-side only main function, will need to implement this for use with trunk' I thought it best to actually provide a base implementation for others to see instead of needing to do that themselves

gbj commented 1 year ago

Sounds good. Merged, and thanks.