@@ -11,6 +11,21 @@ export type Parser = (
1111 loose ?: boolean
1212) => { pattern : RegExp ; keys : string [ ] } ;
1313
14+ // Standard navigation options supported by all built-in location hooks
15+ export type NavigateOptions < S = any > = {
16+ replace ?: boolean ;
17+ state ?: S ;
18+ /** Enable view transitions for this navigation (used with aroundNav) */
19+ transition ?: boolean ;
20+ } ;
21+
22+ // Function that wraps navigate calls, useful for view transitions
23+ export type AroundNavHandler = (
24+ navigate : ( to : Path , options ?: NavigateOptions ) => void ,
25+ to : Path ,
26+ options ?: NavigateOptions
27+ ) => void ;
28+
1429// the object returned from `useRouter`
1530export interface RouterObject {
1631 readonly hook : BaseLocationHook ;
@@ -20,9 +35,19 @@ export interface RouterObject {
2035 readonly parser : Parser ;
2136 readonly ssrPath ?: Path ;
2237 readonly ssrSearch ?: SearchString ;
38+ readonly ssrContext ?: SsrContext ;
2339 readonly hrefs : HrefsFormatter ;
40+ readonly aroundNav : AroundNavHandler ;
2441}
2542
43+ // state captured during SSR render
44+ export type SsrContext = {
45+ // if a redirect was encountered, this will be populated with the path
46+ redirectTo ?: Path ;
47+ // HTTP status code to set for SSR response
48+ statusCode ?: number ;
49+ } ;
50+
2651// basic options to construct a router
2752export type RouterOptions = {
2853 hook ?: BaseLocationHook ;
@@ -31,5 +56,7 @@ export type RouterOptions = {
3156 parser ?: Parser ;
3257 ssrPath ?: Path ;
3358 ssrSearch ?: SearchString ;
59+ ssrContext ?: SsrContext ;
3460 hrefs ?: HrefsFormatter ;
61+ aroundNav ?: AroundNavHandler ;
3562} ;
0 commit comments