Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can part of a website be static site generated and the other be a traditional spa?

So, I've built a website in Nuxt and used ssg. It's great, but for another website 90% of it is all static text and images, but I want a customer login portal where they can see statuses of their products. With my understanding, I don't see how this could be ssg as well. So is it possible to have both?

like image 984
Jacob Ridgwell Avatar asked Jan 28 '26 07:01

Jacob Ridgwell


2 Answers

Vue.js is rendered into #app. Everything outside of that div will be static. So yes, you can have both. BTW, if you don't need SPA completely, check for alphine.js which is a lightweight alternative.

like image 66
Bulent Avatar answered Jan 30 '26 23:01

Bulent


generate-exclude configuration can help you avoiding to SSR specific pages.

So, let's say we have this

export default {
  generate: {
    exclude: [
      /^\/admin/ // path starts with /admin
    ]
  }
}

It will SSR render everything but the admin path, this one will only be available as an SPA generated route.


EDIT to answer to the comments

If you have this kind of structure, all the nested routes under admin will be rendered as SPA pages. blog and pricing would still be universal (server + client rendered).

Also, a simple admin.vue can also do the job yeah (if no more routes needed).

pages
--admin
----secure-dashboard.vue
----info.vue
--blog
--pricing

For the cache, I'm not sure exactly how it behaves but it should still be working, since it's browser side. Not really depending of the type of rendering.

like image 29
kissu Avatar answered Jan 30 '26 23:01

kissu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!