Coder Social home page Coder Social logo

Comments (6)

freddy38510 avatar freddy38510 commented on June 19, 2024

The initial data must be the same between the server and the client in order to avoid hydration mismatch.

If you want to change these data after hydration at client-side, you can use the onMounted Vue hook which will be executed only at-client side.

from quasar-app-extension-ssg.

freddy38510 avatar freddy38510 commented on June 19, 2024

I will try to provide you a simple example based on your needs @adzbuck

Here it is https://stackblitz.com/edit/quasarframework-vj5xbx?file=src/pages/IndexPage.vue

from quasar-app-extension-ssg.

adzbuck avatar adzbuck commented on June 19, 2024

It's not so much changing the data, it's more I don't want to give my build server access to the API.
So I'd want api.xxx.com/example to be replaced with ./build-data/example.js

It would be a great feature if you could display something for SSG then it gets swapped out after hydration.
e.g. a sidebar with the users profile, for SSG It would display a skeleton loader/loader of some sort.. once it's hydrated it hit's the API and swaps it for the real content.

Is this possible at all?

from quasar-app-extension-ssg.

freddy38510 avatar freddy38510 commented on June 19, 2024

In the example I provided the API is never accessed at server-side.

You can replace the initial data by a loading template then with v-if="data === null" and v-else you can switch to the "real content" as soon as the data are fetched at client-side from the onMounted hook.

Edit: I just updated the example, does this fit your needs ?

from quasar-app-extension-ssg.

adzbuck avatar adzbuck commented on June 19, 2024

Ah ok, thank you.. I didn't realise onMounted didn't run on SSG. I can work with that. Thank you for your support.

from quasar-app-extension-ssg.

freddy38510 avatar freddy38510 commented on June 19, 2024

You're welcome. Please just look at the updated example if you haven't already. It might help you.

I am closing this issue. Feel free to reopen or create issues if needed.

from quasar-app-extension-ssg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.