@reckona/mreact-router 0.0.148 → 0.0.149

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -99,7 +99,7 @@ client-only code. Navigation observers are available from
99
99
 
100
100
  ## Route Module Exports
101
101
 
102
- - `loader(context)` returns data passed to the page component, or may return or throw a `Response` for redirects and custom responses. The context includes `params`, `queryClient`, `request`, and adapter `env` when one is provided.
102
+ - `loader(context)` returns data passed to the page component, or may return or throw a `Response` for redirects and custom responses. The context includes `params`, `queryClient`, `request`, and adapter `env` when one is provided. `notFound()` and its explicit alias `throwNotFound()` both throw the router-recognized 404 control-flow error.
103
103
  - `metadata` injects title, OpenGraph, viewport, and related head tags. Use `RouteMetadata` to type the object; `openGraph.image` and `openGraph.images` accept URL scalars or Next-style image objects with a required `url` field.
104
104
  - `generateMetadata(context)` may compute route metadata from resolved loader data, params, and the current request. Static `metadata` is still used as the fallback and base object.
105
105
  - `generateStaticParams()` returns dynamic route params to prerender and can import modules transformed by configured Vite plugins.
@@ -178,6 +178,25 @@ const instrumentation: RouterInstrumentation = {
178
178
  };
179
179
  ```
180
180
 
181
+ Use `definePage<typeof loader>()` when a route page should infer `props.data` and `props.params` from its sibling loader without repeating the loader data shape in the page props annotation:
182
+
183
+ ```tsx
184
+ import { definePage, type LoaderContext } from "@reckona/mreact-router";
185
+
186
+ interface UserData {
187
+ id: string;
188
+ name: string;
189
+ }
190
+
191
+ export async function loader(context: LoaderContext<{ id: string }>): Promise<UserData> {
192
+ return { id: context.params.id, name: "Ada" };
193
+ }
194
+
195
+ export default definePage<typeof loader>(function UserPage(props) {
196
+ return <h1>{props.params.id}: {props.data.name}</h1>;
197
+ });
198
+ ```
199
+
181
200
  Use `InferLoaderData<typeof loader>` when sibling modules need the exact data shape returned by a route loader:
182
201
 
183
202
  ```ts
package/dist/build.js CHANGED
@@ -3551,7 +3551,7 @@ export { defer, isDeferredLoaderData } from ${JSON.stringify(routerDeferredPath)
3551
3551
  export { defineMessages, detectLocale } from ${JSON.stringify(routerI18nPath)};
3552
3552
  export { Link, linkProps } from ${JSON.stringify(routerLinkPath)};
3553
3553
  export { parseMultipartStream } from ${JSON.stringify(routerMultipartPath)};
3554
- export { cookies, headers, html, json, next, notFound, redirect, redirectExternal, rewrite } from ${JSON.stringify(routerNavigationPath)};
3554
+ export { cookies, headers, html, json, next, notFound, redirect, redirectExternal, rewrite, throwNotFound } from ${JSON.stringify(routerNavigationPath)};
3555
3555
  export { getServerRuntimeState } from ${JSON.stringify(routerRuntimeStatePath)};`,
3556
3556
  loader: "js",
3557
3557
  resolveDir: dirname(routerNavigationPath),