← Home

Elder.js Hook: data

data : This hook is run after the route's "data" function has executed.

This hook is mainly used by plugins/hooks to offer functionality at the route level that is dependent on the route's "data" function has returning but isn't suitable to live in multiple data function across many routes due to code duplication.

Examples of things we (ElderGuide.com) have done or have seen users do:

  • LD+JSON: Plugins/hooks that add LD+JSON may need the a route's "data" function to be executed before they have the data needed to run.
  • Breadcrumbs: Plugins/hooks that add breadcrumbs may be dependent on the "data" function of a route.
  • Table Of Contents: Plugins/hooks that automatically generate a table of contents will be dependent on data from a route's data function.
  • Reference Plugins: Plugins/hooks that collect references from content and add them to the footer of the page content.
  • Last Updated Data: Determining the last updated date for a page is often better to do in a central place instead of in many "data" functions.

Stacks are made available here so that strings can be added to the head or footer of the page easily.

Props :
perf
data
request
errors
helpers
query
routes
cssStack
headStack
beforeHydrateStack
hydrateStack
customJsStack
footerStack
settings
next
Mutable :
errors
data
cssStack
headStack
beforeHydrateStack
hydrateStack
customJsStack
footerStack
This hook is an 'advanced' hook meaning it geared towards advanced users or plugins.
Stable · Location: Page.ts
Elder.js hook Lifecycle