Nuxt.js: Is there any asyncData placeholder thing?

Created on 31 Jan 2018  路  6Comments  路  Source: nuxt/nuxt.js

So. I'm fetching some data in asyncData method, of course before my page is loaded. Now, sometimes this data is large and reach data takes a bit. On this state my page is blank and it's not good, is there any way to set some kind of asynData placeholder, loader, something?

@Atinux @alexchopin @pi0

This feature request is available on Nuxt.js community (#c2369)

Most helpful comment

It's a bit more tricky since it has to be fully loaded on server-side. I call this reactive loading and I think I will implement it soon.

The idea is to add a reactive: true property on the page to tell nuxt.js to not wait on client-side but instead call them and add $loading: true in $data. This way you can show a placeholder while asyncData & fetch finish.

All 6 comments

It's a bit more tricky since it has to be fully loaded on server-side. I call this reactive loading and I think I will implement it soon.

The idea is to add a reactive: true property on the page to tell nuxt.js to not wait on client-side but instead call them and add $loading: true in $data. This way you can show a placeholder while asyncData & fetch finish.

@Atinux wouldn't it then just be a SPA template? Would it have anything already rendered in the returned JS?

@Atinux is this an quick thing or should I seek some replacement for this?

@lukasborawski I think this is more or less what I addressed in #2568, there's also a working solution proposal with example there.

@jeroenvisser101 The difference between pure SPA and the proposed approach is that you keep the SSR behaviour, i.e. asyncData gets loaded fully whenever you fetch the page from server, while on client it would behave exactly as SPA.

Because this issue seems to be inactive for quite some time, I'll close it now. If you feel like it deserves some attention because it's not fixed, feel free to ping me and I'll reopen it.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pehbehbeh picture pehbehbeh  路  3Comments

surmon-china picture surmon-china  路  3Comments

msudgh picture msudgh  路  3Comments

uptownhr picture uptownhr  路  3Comments

vadimsg picture vadimsg  路  3Comments