vike icon indicating copy to clipboard operation
vike copied to clipboard

[Guide] `SPA vs SSR`

Open brillout opened this issue 10 months ago • 4 comments

  1. Similarly, the same is true for SPA applications, the relevant knowledge is scattered on different pages, and you need to view and learn in Guides, APIs, Github examples, etc., in order to complete the development and deployment of SPA, SSR and other applications.

brillout avatar Jan 25 '25 12:01 brillout

I think a good guide here would be really appreciated! I used https://github.com/vikejs/vike/tree/main/examples/render-modes to get most what I needed.

However, I still have one open question: how to render/SSG a html entry point for the SPA part of the app? In my case, I'm using my own router for the SPA app, and all I want is fully statically built SPA with it's own static entry point, so I can deploy the entire Vike app statically.

lukebuehler avatar Apr 10 '25 14:04 lukebuehler

Currently, you always have to set prerender: true to deploy to static hosts. In other words, you'll be generating a .html file for each URL. Does that work for you?

We also plan to generate a __spa-fallback.html although you'll have to configure your static host to serve that HTML to each URL.

I agree that a good guide would be nice!

brillout avatar Apr 11 '25 07:04 brillout

Yes, I would love to have a guide how to achieve basically what RR describes here: https://reactrouter.com/how-to/pre-rendering#pre-rendering-with-a-spa-fallback

But it is still not clear how I would achieve that with Vike, because if I turn prerendering on for the SPA I get tonns of errors, which is obvious because it's trying to render all kinds of SPA libs (e.g. in my case Clerk auth and others).

lukebuehler avatar Apr 11 '25 08:04 lukebuehler

But it is still not clear how I would achieve that with Vike, because if I turn prerendering on for the SPA I get tonns of errors, which is obvious because it's trying to render all kinds of SPA libs (e.g. in my case Clerk auth and others).

That shouldn't be the case. Can you publish a minimal reproduction?

Let's create a new issue/discussion about this.

brillout avatar Apr 14 '25 10:04 brillout