Nuxt.js: Remove asyncData for full static export

Created on 19 May 2020  路  4Comments  路  Source: nuxt/nuxt.js

Version

nuxt-edge

Reproduction link

Any nuxt project

Steps to reproduce

  • Switch to nuxt-edge on any nuxt project
  • Enable target: static
  • Build and export it

What is expected ?

Nuxt should export the static site with asyncData removed. It isn't needed for static export (payload.js is used instead) => unnecessary data for the user to download.

What is actually happening?

Nuxt keeps asyncData.

chrome_2020-05-19_17-31-46.png

This bug report is available on Nuxt community (#c10677)
bug-report

All 4 comments

It is still necessary for the following situations:

  • In case the payload can't be fetched
  • When using SPA fallback (no payload in this case)
  • When using preview mode

Hello @manniL

thank you for your reply! I've some questions.

In case the payload can't be fetched

When can't the payload be fetched? If the user lacks of network access? The API would be unavailable, too.

When using SPA fallback (no payload in this case)

Isn't the full static export a static site which hydrates to a SPA without API requests? => we don't need asyncData.

When using preview mode

What do you mean with "preview mode"? Running Nuxt in dev?

When can't the payload be fetched? If the user lacks of network access? The API would be unavailable, too.

The most common situation I can think of is when using the SPA fallback (as there won't be a payload). But there might be other scenarios where this comes in handy instead of letting the site break.

When using SPA fallback (no payload in this case)
Isn't the full static export a static site which hydrates to a SPA without API requests? => we don't need asyncData.

Yes, this is correct so far. But you can exclude routes from being generated (e.g. everything behind authentication). Those have no payload but can still be accessed "normally" and will load as "SPA" (no generated HTML)

When using preview mode
What do you mean with "preview mode"? Running Nuxt in dev?

See https://github.com/nuxt/nuxt.js/pull/6159#issuecomment-631608962

@manniL
Thank you very much for answering my questions! It's clear now 馃槈

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nassimbenkirane picture nassimbenkirane  路  3Comments

surmon-china picture surmon-china  路  3Comments

mattdharmon picture mattdharmon  路  3Comments

bimohxh picture bimohxh  路  3Comments

o-alexandrov picture o-alexandrov  路  3Comments