UNPKG

@tanstack/router-core

Version:

Modern and scalable routing for React applications

1 lines 1.59 kB
{"version":3,"file":"not-found.cjs","names":[],"sources":["../../src/not-found.ts"],"sourcesContent":["import type { RouteIds } from './routeInfo'\nimport type { RegisteredRouter } from './router'\n\nexport type NotFoundError = {\n /**\n @deprecated\n Use `routeId: rootRouteId` instead\n */\n global?: boolean\n /**\n @private\n Do not use this. It's used internally to indicate a path matching error\n */\n _global?: boolean\n data?: any\n throw?: boolean\n routeId?: RouteIds<RegisteredRouter['routeTree']>\n headers?: HeadersInit\n}\n\n/**\n * Create a not-found error object recognized by TanStack Router.\n *\n * Throw this from loaders/actions to trigger the nearest `notFoundComponent`.\n * Use `routeId` to target a specific route's not-found boundary. If `throw`\n * is true, the error is thrown instead of returned.\n *\n * @param options Optional settings including `routeId`, `headers`, and `throw`.\n * @returns A not-found error object that can be thrown or returned.\n * @link https://tanstack.com/router/latest/docs/router/framework/react/api/router/notFoundFunction\n */\nexport function notFound(options: NotFoundError = {}) {\n ;(options as any).isNotFound = true\n if (options.throw) throw options\n return options\n}\n\n/** Determine if a value is a TanStack Router not-found error. */\nexport function isNotFound(obj: any): obj is NotFoundError {\n return !!obj?.isNotFound\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,SAAgB,SAAS,UAAyB,EAAE,EAAE;AAClD,SAAgB,aAAa;AAC/B,KAAI,QAAQ,MAAO,OAAM;AACzB,QAAO;;;AAIT,SAAgB,WAAW,KAAgC;AACzD,QAAO,CAAC,CAAC,KAAK"}