Skip to content

Add payload extraction for large data fetched during SSR to avoid rendering in HTML #33019

@adamdehaven

Description

@adamdehaven

Describe the feature

When fetching large amounts of data during server-side rendering, Nuxt currently inlines the payload directly into the rendered HTML. This can cause performance issues for pages that rely on large datasets that can't be scaled down with existing solutions (e.g. pick).

For example, we have a page that fetches an OpenAPI Specification (OAS) via a custom $fetch client. Since the entire OAS is inlined in the SSR output, the HTML response size can become extremely large (often 1MB or more). This negatively impacts performance by blocking TTFB and forcing the browser to download and parse a much larger HTML document than necessary.

A possible improvement would be to provide an opt-in way to externalize large payloads into a separate file, with the server-rendered HTML referencing it rather than embedding it inline. This would keep the HTML response small, improve TTFB, and still allow hydration to work seamlessly since the payload would be fetched alongside the page.

Ideally, this could be supported regardless of whether the data is fetched with useAsyncData, useFetch, or a custom $fetch client, while remaining optional so that existing behavior continues to work by default.

Additional information

  • Would you be willing to help implement this feature?
  • Could this feature be implemented as a module?

Final checks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions