Knowledgebase

Data Fetching and State in Nuxt Applications Print

  • frontenddevelopment, frontend, caching, errors, guide, howto, solution, zillionkinghost
  • 0

Loading and sharing data.

WHAT THE FRAMEWORK PROVIDES

Composables for fetching, handling server and client execution correctly.

WHAT THEY HANDLE

Fetching during server rendering, without refetching on the client Deduplication Caching Loading and error states

WHY THAT MATTERS

Fetching naively in a universal application requests everything twice.

WHAT TO BE CAREFUL WITH

Data fetched on the server that contains anything sensitive Keys or secrets used in code that also runs in the browser

WHAT TO ESTABLISH

Which code runs where.

WHAT THE SERVER LAYER PROVIDES

Endpoints within the same application, for handling requests and hiding secrets.

WHAT TO USE IT FOR

Anything requiring a key, or anything that should not run in the browser.

WHAT TO USE FOR SHARED STATE

The official state library, which handles server rendering correctly.

WHY NOT A PLAIN SHARED OBJECT

On the server, it would be shared between requests and therefore between users.

WHAT THAT WOULD CAUSE

One user seeing another's data, which is a serious fault.

WHAT TO TEST

The initial server response, and behaviour on navigation.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot