chinedufn / percy

Build frontend browser apps with Rust + WebAssembly. Supports server side rendering.
https://chinedufn.github.io/percy/
Apache License 2.0
2.26k stars 84 forks source link

support for "universal" pre-rendered static apps planned? #141

Open JakubKoralewski opened 4 years ago

JakubKoralewski commented 4 years ago

Is something like Nuxt's "universal" setting planned to be supported? Where a frontend app's all routes are rendered and saved to html files for faster loads?

chinedufn commented 4 years ago

Not necessarily planned at the moment - but definitely interested in supporting and/or making it easy to generate a static site for an application.

Right now to serve an application pre-rendered you need to be running a Rust server somewhere.

It would be nice if you had the option of generating a static site for your application instead.

At the moment you can accomplish a similar "fastest possible page load" by putting a CDN in front of the Rust server - but yeah not needing to have a server is a nice option.

Whether or not that would happy in this repository or left to user-land I'm not sure yet - but it's something that we'll want to think through.

My current priority is re-thinking state management and writing a crate around that - but this is definitely something we should be thinking about.

llebout commented 4 years ago

To clarify if I misunderstood the post above, I would be interested in having SSR for every page, like to never have the client take over. The goal being, getting back to lightweight HTML-only websites of the PHP era with the least amount of JavaScript possible if at all.

Would that be possible? The new programming paradigms offered by modern frontend frameworks are interesting, but they imply an enormous cost on clients.

chinedufn commented 4 years ago

At this very moment you can do SSR with Percy and not have any sort of client side code running. How / where could I make that more clear?

If we had anything around static-site generation (I haven't thought about it yet. Might be better in user-land for all I know) you would not need any client side code for that case as well.

More clearly.

Percy doesn't force you to have SSR or client side rendering. You use whatever you want.

The general philosophy of Percy is to give you libraries to use but make you fairly explicitly decide to use them (Percy just recommends to you how/where to do it).

This way you don't end up with the currently-common case of "I just want to do X but this framework is making ABCDEFGHI and J happen"

oovm commented 3 years ago

I have some idea.

If we generate all static pages based on the route, we still need a runtime to handle events.

Visit each SSG (static-site generation) page, they only correspond to a different initial state, right?

To access any of these pages, introduce the same runtime, and then convert the page into PWA, the next rendering is just to read json to change the state.

Of course this means that each page must generate additional json metadata, and html is just an entry point, or a state snapshot.