Skip to content

Add type-safe custom data for notFound #7774

Description

@LadyBluenotes

notFound({ data }) currently accepts any, while notFoundComponent receives data as unknown. This forces consumers to add their own type guards or casts.

Add a shared type-safe way to configure custom not-found data. The solution should:

  • Work through the shared router-core NotFoundError type.
  • Type notFound, routeApi.notFound, and NotFoundRouteProps.data consistently.
  • Cover React, Solid, and Vue bindings.
  • Decide whether the type is global through Register or configurable per route.
  • Preserve existing behavior for applications that do not configure a custom type.
  • Add type tests for returned and thrown not-found errors.
  • Update the notFound reference documentation with the supported augmentation pattern.
  • Avoid runtime or bundle-size changes.

Related: #3112 and discussion #3113.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    No fields configured for Enhancement.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions