@solidnative-dev/navigation 0.0.0-stage → 0.1.0-alpha.0

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
@@ -1,3 +1,923 @@
1
- # Temporary Holding Version
1
+ # `@solidnative-dev/navigation`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ TanStack Router owns route matching, params, loaders, redirects, and navigation
4
+ state. `createTanStackNativeHistory` implements its pinned framework-neutral
5
+ history contract over `NativeHistory`, while `createTanStackNativeRouter`
6
+ instantiates the routing core with Solid 2-owned signals and memos. Solid 2's
7
+ `flush(fn)` is the atomic store-publication boundary; the integration does not
8
+ install the published Solid 1 component package or create a competing route
9
+ matcher:
10
+
11
+ ```ts
12
+ const rootRoute = new TanStackRootRoute();
13
+ const homeRoute = new TanStackRoute({
14
+ getParentRoute: () => rootRoute,
15
+ path: "/",
16
+ loader: () => loadHome(),
17
+ component: Home,
18
+ });
19
+ const routeTree = rootRoute.addChildren([homeRoute]);
20
+ const nativeHistory = new NativeHistory({ initialHref: "/" });
21
+ const routerHistory = createTanStackNativeHistory(nativeHistory);
22
+
23
+ const router = createTanStackNativeRouter({
24
+ routeTree,
25
+ history: routerHistory,
26
+ isServer: false,
27
+ });
28
+
29
+ <TanStackNativeRouterProvider router={router}>
30
+ <TanStackNativeMatches />
31
+ </TanStackNativeRouterProvider>;
32
+ ```
33
+
34
+ The provider owns the history subscription, initial load, and Solid 2 router
35
+ publication boundary. `TanStackNativeMatches` renders nested route components
36
+ and `TanStackNativeOutlet` boundaries directly into native nodes. Route options
37
+ accept native `component`, `pendingComponent`, `errorComponent`, and
38
+ `notFoundComponent` functions. Loader failures retry through invalidation;
39
+ component failures reset through a Solid 2 `Errored` boundary. Registered-router
40
+ typing flows through `useTanStackNativeMatch` and
41
+ `useTanStackNativeLoaderData`, including route-ID validation and route-specific
42
+ params/loader data. `TanStackNativeRouteView` remains the lower-level explicit
43
+ callback projection when an application does not want route option components.
44
+ No path uses React or a DOM provider. The factory also disables TanStack core's
45
+ browser scroll-reset listener. Native scroll ownership remains local to each
46
+ container; `TanStackNativeScrollView` restores a remounted container without
47
+ installing a browser-style global scroll registry.
48
+
49
+ `TanStackNativeLink` turns the registered-router navigation contract into a
50
+ real native `Pressable`. Its render state is backed by Solid memos over
51
+ TanStack's committed and pending locations, plus the native gesture and the
52
+ link's own unsettled navigation request:
53
+
54
+ ```tsx
55
+ <TanStackNativeLink
56
+ options={{ to: "/detail/$id", params: { id: item.id } }}
57
+ activeOptions={{ includeSearch: false }}
58
+ preload="intent"
59
+ pressableProps={{
60
+ accessibilityLabel: `Open ${item.title}`,
61
+ testID: `detail-${item.id}`,
62
+ }}
63
+ onNavigationError={(error) => diagnostics.capture(error)}
64
+ >
65
+ {(state) => (
66
+ <Text style={{ opacity: state.pressed ? 0.6 : 1 }}>
67
+ {state.isTransitioning ? "Opening…" : item.title}
68
+ </Text>
69
+ )}
70
+ </TanStackNativeLink>
71
+ ```
72
+
73
+ `pressed`, `isActive`, `isPending`, `isTransitioning`, and `isPreloading` are
74
+ getter-backed reactive values, so consumers update only the computations that
75
+ read them. `preload="intent"` starts TanStack preloading at native press-in;
76
+ `preload="render"` starts after the component's first Solid settlement. When
77
+ the prop is omitted, compatible `defaultPreload` router policies apply. A web
78
+ `viewport` default deliberately becomes no preloading because the native
79
+ component does not invent a DOM observer; applications can select `render`
80
+ explicitly. Preload work is deduplicated per link, failures are isolated
81
+ through `onPreloadError`, and late completion cannot write into a disposed
82
+ Solid owner.
83
+
84
+ Duplicate presses are ignored until the current navigation settles. The link
85
+ owns `accessibilityRole`, `disabled`, and the selected/busy accessibility
86
+ state; other native interaction, style, ref, label, and testing props pass
87
+ through `pressableProps` reactively. Browser-only `href` and
88
+ `reloadDocument` options fail closed. External URLs belong to the platform
89
+ linking service, while this component remains an in-application native route
90
+ primitive.
91
+
92
+ With causal telemetry enabled, the press starts a privacy-safe
93
+ `navigation.link` task. TanStack's immediate pending publication and its later
94
+ loader settlement both re-enter that task, so the final native commit does not
95
+ lose the initiating press at an `await` boundary. Programmatic navigation uses
96
+ the matching `navigation.programmatic` task. Neither operation records the
97
+ destination, params, search state, loader value, or error message. Navigation
98
+ is latest-wins per router: a newer request cancels the displaced task, and
99
+ provider/root disposal cancels an unfinished task.
100
+
101
+ The checked-in Pixel 9a Release process suite exercises this public link with
102
+ a real 75 ms async detail loader. It requires the Fabric press to cause the
103
+ `navigation.link` task, a separately flushed pending frame, and the eventual
104
+ normal-priority native commit. The assertion also limits task attributes to
105
+ the static runtime resource and task-name keys above. Seed, memory-pressure,
106
+ and every one of 30 native churn navigations pass this causal settlement check.
107
+ The last promoted signed-iPhone product process physically exercised the same
108
+ public link and required its async detail plus the later interrupted sheet route
109
+ to retain bounded causal ownership through their final normal-priority commits.
110
+ The current shared-entrypoint candidate is held at `native-integrated` until
111
+ that complete physical process reruns.
112
+
113
+ Programmatic navigation uses the same registered route types. A default
114
+ `from` keeps relative transitions local to the calling route:
115
+
116
+ ```tsx
117
+ const navigate = useTanStackNativeNavigate({ from: "/login" });
118
+
119
+ await navigate({ to: "../home" });
120
+ ```
121
+
122
+ Route-entry authentication should stay in TanStack's routing state machine,
123
+ not a component effect. `tanStackRedirect` is the package-level re-export of
124
+ the core redirect primitive:
125
+
126
+ ```ts
127
+ const protectedRoute = new TanStackRoute({
128
+ getParentRoute: () => rootRoute,
129
+ path: "/protected",
130
+ beforeLoad: ({ context }) => {
131
+ if (!context.session()) {
132
+ throw tanStackRedirect({ to: "/login", replace: true });
133
+ }
134
+ },
135
+ });
136
+ ```
137
+
138
+ With the native history adapter, `replace: true` removes the protected entry
139
+ instead of leaving pre-authentication content behind the system Back action.
140
+ The navigate hook also rejects browser-only `href` and `reloadDocument`
141
+ options; external destinations continue through the platform linking service.
142
+
143
+ The Pixel 9a Release product proof combines these contracts rather than testing
144
+ them as isolated helpers. An unauthenticated `/protected` launch redirects by
145
+ replacement to `/login`; a physical sign-in press begins a slow `/slow` load,
146
+ and a second physical press interrupts it with an absolute
147
+ `navigate({ to: "/home", replace: true })`. The displaced
148
+ `navigation.programmatic` task is canceled, the winning task owns a separately
149
+ flushed pending frame and the final normal-priority native commit, and late
150
+ loader bookkeeping is causally detached and cannot change route or history.
151
+ The retained pending `Screen` becomes `/home` without leaking a third native
152
+ container. Android Back then reveals the original login `Screen`, with native
153
+ history exactly `[/login, /home]` at index zero and balanced Solid owners at
154
+ teardown.
155
+
156
+ For platform stack presentation, `TanStackNativeStack` couples those match
157
+ trees to `NativeStack`'s keyed screen owners. A visited screen keeps its last
158
+ settled match snapshot while inactive, so its route components, local Solid
159
+ state, and native handles survive a push and are reused on Back. Route
160
+ components can read the owning entry, index, and native focus accessor through
161
+ `useTanStackNativeScreen`. `renderUnresolved` is deliberately required: a
162
+ restored historical entry may not yet have been visited by the single-current-
163
+ location TanStack core, so the application must supply a safe native placeholder
164
+ until that index receives its first settled match.
165
+
166
+ Mounted route ownership has a separate opt-in budget. A reactive
167
+ `maxMountedRouteTrees` value counts the current route plus the nearest inactive
168
+ route trees. Older trees are parked: their Solid component owners and native
169
+ content nodes dispose, while their keyed native `Screen` containers, history
170
+ entries, and settled TanStack snapshots remain. Raising the budget remounts a
171
+ parked tree without navigating or replacing its screen container. Applications
172
+ can distinguish this state with `renderParked`; when it is omitted,
173
+ `renderUnresolved` is reused.
174
+
175
+ ```tsx
176
+ const memoryPolicy = createTanStackNativeMemoryPolicy(platformServices, {
177
+ normalMountedRouteTrees: 8,
178
+ pressuredMountedRouteTrees: 2,
179
+ onMemoryPressure: (warningCount) =>
180
+ Promise.all(applicationCaches.map((cache) => cache.reclaim(warningCount))),
181
+ onMemoryPressureError: (error, warningCount) =>
182
+ diagnostics.capture(error, { warningCount }),
183
+ });
184
+
185
+ <TanStackNativeStack
186
+ history={history}
187
+ memoryPolicy={memoryPolicy}
188
+ renderUnresolved={() => <LoadingScreen />}
189
+ renderParked={() => <ParkedScreen />}
190
+ />;
191
+
192
+ // Call only after the application has evidence that its working set is safe.
193
+ memoryPolicy.acknowledgeRecovery();
194
+ ```
195
+
196
+ The current route is always inside any valid budget. A limit of `1` parks the
197
+ immediate predecessor too, so gesture-driven stacks should normally retain at
198
+ least `2` or intentionally provide a gesture-safe parked presentation. Parking
199
+ recreates component-local state when the tree mounts again; it does not rewrite
200
+ navigation history. Without a memory policy, it also retains settled TanStack
201
+ snapshots and the router's loader cache. The default remains unbounded to
202
+ preserve existing state-retention semantics.
203
+
204
+ Route trees that contain long native content can use
205
+ `TanStackNativeScrollView` to keep the last finite native offset alongside the
206
+ stable history-entry identity:
207
+
208
+ ```tsx
209
+ function FeedRoute() {
210
+ return (
211
+ <TanStackNativeScrollView
212
+ restorationKey="feed"
213
+ onRestorationError={(error, entry) =>
214
+ diagnostics.capture(error, { route: entry.href })
215
+ }
216
+ >
217
+ <Feed />
218
+ </TanStackNativeScrollView>
219
+ );
220
+ }
221
+ ```
222
+
223
+ Each `TanStackNativeStack` owns a bounded entry-keyed offset registry. Native
224
+ scroll events update only that entry's named container. When parking or memory
225
+ pressure remounts its route tree, the replacement `ScrollView` receives one
226
+ non-animated native `scrollTo` after the screen is focused. A retained native
227
+ container is never commanded again merely because its screen blurs and
228
+ refocuses. Transient negative UIKit bounce offsets are clamped to zero, invalid
229
+ payloads are isolated through `onRestorationError`, and a continuous run of
230
+ capture failures reports once until a valid event recovers so a bad native
231
+ stream or full registry cannot flood diagnostics at scroll cadence. Entries
232
+ removed by a push/reset are pruned. Each entry can retain at most 32 named
233
+ containers. This works in memory by default. For process-death restoration, create a
234
+ `NativeScrollRestoration` from the versioned stored snapshot and pass it to the
235
+ stack's `scrollRestoration` prop. The storage launch helper accepts offsets only
236
+ when navigation itself reports `source: "restoration"`; a fresh or deep-link
237
+ launch deletes stale offsets so a newly generated screen ID cannot inherit an
238
+ older process's position. Storage writes are serialized and coalesced behind
239
+ the same vendor-neutral adapter contract as history persistence.
240
+
241
+ `createTanStackNativeMemoryPolicy(platformServices, options)` owns that warning
242
+ subscription on both pinned backends and exposes the count, pressure state, and
243
+ reactive route-tree limit. While pressure is active, `TanStackNativeStack`
244
+ cancels restoration prewarming, calls the pinned router's public `clearCache`
245
+ boundary to abort and evict inactive/preloaded matches, and discards its own
246
+ inactive settled snapshots. The current match, keyed native screens, and native
247
+ history remain intact. `acknowledgeRecovery()` restores the normal mount budget
248
+ without resurrecting discarded loader data. An explicit
249
+ `maxMountedRouteTrees` prop still acts as an additional upper bound.
250
+
251
+ iOS warnings enter through the native AppState event. The generated Android
252
+ application forwards actual memory-pressure callback levels through the
253
+ package-owned `SolidNativePlatformAndroid` TurboModule while excluding ordinary
254
+ `UI_HIDDEN` backgrounding. External caches such as TanStack Query, decoded
255
+ images, and inactive AI streams remain application-owned. `onMemoryPressure`
256
+ lets them join each warning generation without coupling navigation to a cache
257
+ vendor. Its return value is deliberately not awaited, so cache work cannot
258
+ delay route-tree reclamation; sync throws and promise rejections are isolated
259
+ and delivered to `onMemoryPressureError` when provided.
260
+
261
+ Applications can opt into bounded restored-stack work with
262
+ `preloadRestoredEntries`. After the current route has genuinely resolved, the
263
+ stack preloads that many nearest prior entries sequentially and mounts their
264
+ route trees inside the existing inactive screen owners. It never changes the
265
+ current router/native location, never starts without an explicit positive
266
+ bound, and never mounts a late result after disposal. An unselected entry or a
267
+ preload that yields no compatible match keeps using `renderUnresolved`;
268
+ `shouldPreloadRestoredEntry(entry, index, signal)` can synchronously or
269
+ asynchronously skip candidates inside that bound before any loader starts. Its
270
+ shared signal aborts as soon as memory pressure begins or the stack owner
271
+ disposes. `onPreloadError` observes selection and setup failures that escape
272
+ TanStack's own preload result handling. Like the package's other explicit
273
+ diagnostic hooks, it is an isolated observer: both synchronous throws and
274
+ rejected return values are contained instead of replacing the navigation
275
+ failure or safe fallback it observed.
276
+
277
+ Dedicated Pixel and iPhone Release proofs persist a root/detail stack, tear down
278
+ its Solid surface, terminate the package, and restore detail under a new process
279
+ ID on an ordinary no-URL launch. With `preloadRestoredEntries: 1`, Android
280
+ system Back or an iPhone left-edge interactive pop reveals the resolved prior
281
+ root instead of the unresolved fallback while retaining detail as the forward
282
+ entry. A third process proves an accepted cold URL clears competing durable
283
+ history before persistence begins. Both platforms validate the native stack,
284
+ route loaders, ownership accounting, and non-terminating surface teardown.
285
+
286
+ Retained route owners and ordinary Solid computations stay live while a screen
287
+ is covered. This preserves local state and keeps fine-grained application data
288
+ semantics unsurprising. Work that should exist only while the operating system
289
+ considers a screen focused—camera sessions, sensors, expensive subscriptions,
290
+ or timers—can opt into a narrower native lifecycle scope:
291
+
292
+ ```ts
293
+ createTanStackNativeScreenFocusEffect(() => {
294
+ const subscription = locationService.watch(updateLocation);
295
+ return () => subscription.remove();
296
+ });
297
+ ```
298
+
299
+ Promise-based work can use an abort-aware scope instead. Each focus interval
300
+ gets a fresh standard `AbortSignal`; blur, Back/reset removal, or parent
301
+ disposal aborts it before another interval starts. Rejections that arrive after
302
+ that cancellation are stale and ignored, while failures from the active
303
+ interval reach `onError` (or the global error path when no handler is supplied):
304
+
305
+ ```ts
306
+ createTanStackNativeScreenFocusTask(
307
+ async (signal) => {
308
+ const response = await fetch(detailURL, { signal });
309
+ setDetail(await response.json());
310
+ },
311
+ {
312
+ enabled: () => appState() === "active",
313
+ onError: reportRouteError,
314
+ },
315
+ );
316
+ ```
317
+
318
+ The optional reactive `enabled` gate intersects with native focus. Closing it
319
+ aborts the current interval; reopening it while the screen remains focused
320
+ starts a fresh one. This lets backgrounding, connectivity, consent, or power
321
+ policy stop work without changing the retained route owner.
322
+
323
+ Screens can also opt into a single platform accessibility-focus move after
324
+ each positive native appear event. The target accessor is resolved only after
325
+ the keyed route subtree has mounted, so it can close over an ordinary native
326
+ ref without exposing a React tag:
327
+
328
+ ```ts
329
+ let heading: NativeNode | undefined;
330
+
331
+ createTanStackNativeScreenAccessibilityFocus(() => heading);
332
+
333
+ return <Text ref={(node) => (heading = node)}>Order details</Text>;
334
+ ```
335
+
336
+ `createNativeScreenAccessibilityFocus(isFocused, target)` provides the same
337
+ policy for a direct `NativeStack` child. Target resolution waits for the
338
+ focused Solid subtree to settle, including when an async or restored route's
339
+ native Screen appears before its match component and ref. Blur or owner
340
+ disposal cancels that pending focus interval. The underlying Fabric operation
341
+ uses the mounted shadow node and React Native's cross-platform accessibility
342
+ event path; it is distinct from input focus.
343
+
344
+ The signed Pixel Release process suite observes Android's real
345
+ `TYPE_VIEW_FOCUSED` events for both the root heading and the pushed detail
346
+ heading, then continues through restoration and 30 native push/Back cycles.
347
+ The same navigation entry and Objective-C++ Fabric path compile as a generic
348
+ iOS Release/ARM64 application; a VoiceOver-focused physical iPhone assertion
349
+ remains a separate device proof.
350
+
351
+ Setup begins only after a positive native focus event. Cleanup runs on blur,
352
+ Back/reset disposal, or parent disposal, and setup can run again when the same
353
+ retained owner regains focus. `createNativeScreenFocusEffect(isFocused, setup)`
354
+ provides the same synchronous policy for the accessor passed directly by
355
+ `NativeStack`; `createNativeScreenFocusTask(isFocused, task, options)` provides
356
+ the corresponding abort-aware asynchronous policy.
357
+ Solid Native does not globally pause an owner graph: that would hide updates,
358
+ change ordinary signal semantics, and offer no safe rule for pending async work.
359
+
360
+ The physical Pixel Release proof runs this projection end to end: TanStack
361
+ loaders publish the root, detail, and deep-link matches; native Back restores
362
+ the original root Solid owner and Fabric handle; and a cold deep-link reset
363
+ replaces the keyed screen with a newly matched root component. It also requires
364
+ exactly one focus-owned work scope across the root/detail transition, reacquires
365
+ the retained root's scope on Back, and balances every setup during teardown.
366
+ The dedicated process runner additionally performs 30 physical push/system-Back
367
+ cycles against one retained Java `ScreenStack`, balances 30 detail owners, and
368
+ observes TanStack's expected zero-stale root-loader revalidation without
369
+ recreating the keyed root component.
370
+ Metro is required to canonicalize Solid's conditional exports so router stores
371
+ and native render effects participate in the same reactive graph.
372
+
373
+ Adapter push, replace, back, forward, and arbitrary traversal publish exactly
374
+ one TanStack update. Native deep links and completed platform backs enter from
375
+ the other direction and are translated without echoing a second native
376
+ transition. TanStack location keys and indices are transport-safe, survive
377
+ `NativeHistory` persistence, and are repaired for older restored entries that
378
+ did not contain them. Async TanStack blockers cover programmatic traversal and
379
+ register with `NativeHistory` while active. Android Back is consumed until the
380
+ decision settles; iOS `preventNativeDismiss` holds the screen and reports the
381
+ attempt so an allowed result can pop through ordinary Solid reconciliation.
382
+ `ignoreBlocker` retains the same explicit bypass semantics as upstream history.
383
+ Naturally canceled iOS gestures surface through `onPlatformBackCancel`, while a
384
+ blocker-rejected attempt surfaces separately through `onPlatformBackBlocked`.
385
+
386
+ `NativeStack` is the first Solid-owned presentation primitive. It keeps one
387
+ keyed Solid owner per history entry, renders the active history prefix into
388
+ native `Screen`/`ScreenStack` containers, acknowledges application transitions
389
+ after the native stack finishes, and reconciles platform dismissals without a
390
+ router/native feedback loop. A same-screen `replace` is acknowledged
391
+ immediately because it updates the retained container without starting a
392
+ native transition. Disposing a stack or modal presenter drains any remaining
393
+ acknowledgements it owns so a longer-lived history does not retain orphaned
394
+ transaction IDs. Its child callback receives accessors so route content can
395
+ stay reactive without losing screen identity:
396
+
397
+ ```tsx
398
+ const history = new NativeHistory({ initialHref: "/" });
399
+
400
+ <NativeStack
401
+ history={history}
402
+ defaultScreenOptions={{
403
+ gestureEnabled: true,
404
+ nativeBackButtonDismissalEnabled: true,
405
+ presentation: "push",
406
+ }}
407
+ onScreenFocus={(entry, event) => recordVisibility(entry, event)}
408
+ renderHeader={(entry) => (
409
+ <ScreenHeader title={entry().href === "/" ? "Home" : "Detail"}>
410
+ {entry().href === "/detail" ? (
411
+ <ScreenHeaderSubview type="right">
412
+ <Pressable accessible accessibilityRole="button" onPress={saveDetail}>
413
+ <Text>Save</Text>
414
+ </Pressable>
415
+ </ScreenHeaderSubview>
416
+ ) : null}
417
+ </ScreenHeader>
418
+ )}
419
+ >
420
+ {(entry, _index, isFocused) =>
421
+ entry().href === "/" ? (
422
+ <Home isFocused={isFocused} />
423
+ ) : (
424
+ <Detail entry={entry()} isFocused={isFocused} />
425
+ )
426
+ }
427
+ </NativeStack>;
428
+ ```
429
+
430
+ `defaultScreenOptions` is a reactive navigator-wide layer on both
431
+ `NativeStack` and `NativeTabs`. The keyed entry/tab `screenOptions` result is
432
+ shallowly applied after those defaults, so matching keys override and an
433
+ explicit `undefined` clears an inherited value. Reactive non-structural changes
434
+ update the existing native nodes without recreating their Solid owners. A
435
+ stack entry captures `presentation` when its keyed owner is created because the
436
+ native push/modal/sheet container is structural. Nested values such as styles
437
+ and tab special effects remain atomic; compose them explicitly when an
438
+ application needs a deeper merge.
439
+
440
+ Sheet presentation is part of each keyed route's `screenOptions`, so changing a
441
+ native detent does not recreate the route component or its Solid owner:
442
+
443
+ ```tsx
444
+ <NativeStack
445
+ history={history}
446
+ screenOptions={(entry) =>
447
+ entry.href === "/checkout"
448
+ ? {
449
+ presentation: "sheet",
450
+ sheetAllowedDetents: [0.45, 0.9],
451
+ sheetInitialDetent: "last",
452
+ sheetGrabberVisible: true,
453
+ }
454
+ : { presentation: "push" }
455
+ }
456
+ onScreenSheetDetentChange={(entry, event) =>
457
+ recordDetent(entry.id, event.payload.index, event.payload.isStable)
458
+ }
459
+ >
460
+ {(entry, index, isFocused) => (
461
+ <RouteContent entry={entry()} depth={index()} focused={isFocused()} />
462
+ )}
463
+ </NativeStack>
464
+ ```
465
+
466
+ Detent arrays are transport-safe ascending ratios, with a portable maximum of
467
+ three enforced on Android; `"fitToContents"` is also supported. Native events
468
+ are runtime-validated before the typed callback receives `{ index, isStable }`.
469
+ The Pixel Release proof physically drags a two-detent Material sheet, observes
470
+ detent `0` in Solid-owned accessible output, persists the sheet route, and then
471
+ restores the same history in a fresh process. The signed iPhone Release proof
472
+ presents the same route through `RNSModalScreen`, physically moves the UIKit
473
+ grabber from expanded to half-screen, observes stable detent `0` through Solid,
474
+ requires the keyed route content to survive the geometry change, and balances
475
+ sheet/Fabric teardown.
476
+
477
+ `NativeModalStack` covers standalone platform modals without pretending they
478
+ are native-stack sheets. Entry `0` is retained application content; every later
479
+ active `NativeHistory` entry is a keyed `Modal` route. The same history can
480
+ therefore use push, Back, restoration, deep links, persistence, and blockers:
481
+
482
+ ```tsx
483
+ <NativeModalStack
484
+ history={history}
485
+ defaultModalOptions={{
486
+ allowSwipeDismissal: true,
487
+ animationType: "slide",
488
+ presentationStyle: "pageSheet",
489
+ }}
490
+ modalOptions={(entry) => ({
491
+ accessibilityLabel: `Modal ${entry.href}`,
492
+ })}
493
+ onPlatformBackBlocked={(entry) => recordBlockedClose(entry.href)}
494
+ >
495
+ {(entry, _index, isFocused) => (
496
+ <RouteContent entry={entry()} focused={isFocused()} />
497
+ )}
498
+ </NativeModalStack>
499
+ ```
500
+
501
+ Modal entries form a real nested portal hierarchy rather than a set of sibling
502
+ overlays. That matches Android's Dialog ordering and UIKit's requirement that
503
+ each successive sheet be presented from the preceding modal host. Application
504
+ pops first commit `visible=false`, retain every affected modal route owner, and
505
+ dismiss only the topmost modal. Each next dismissal starts after the preceding
506
+ core facade reports its cross-platform `onHidden` boundary; the complete
507
+ history transition is acknowledged only after the requested stack depth is
508
+ reached. Android reaches that boundary after its Dialog is removed; iOS retains
509
+ the Fabric event route through UIKit's asynchronous dismissal callback. Native close requests enter
510
+ `requestPlatformBack`, including async blocker arbitration, before mutating
511
+ history. While blockers exist, iOS swipe dismissal is disabled so a gesture
512
+ cannot outrun the decision. Restored modal entries mount directly without a
513
+ synthetic transition, and removed owners release their detached parking trees
514
+ instead of surviving until application shutdown.
515
+
516
+ A dedicated signed iPhone Release proof presents two real UIKit page sheets.
517
+ Application Back closes the first only after its hidden boundary; a physical
518
+ drag against the second is rejected while a Solid platform blocker is active;
519
+ and another physical drag dismisses it after a native button reactively removes
520
+ that blocker. React Native's accepted interactive-dismissal `requestClose` is
521
+ normalized into one portable dismissal/hidden sequence, producing exactly one
522
+ platform pop, two disposed modal owners, a retained application owner, and a
523
+ clean Fabric surface stop without terminating the app process.
524
+
525
+ The third child accessor follows actual native screen lifecycle rather than
526
+ merely the current history index. A native `appear` focuses its keyed owner and
527
+ reactively blurs the other owners in the same stack; a backend `disappear` also
528
+ blurs its owner when supplied. Reading the accessor creates a narrowly scoped
529
+ Solid dependency. `onScreenFocus` and `onScreenBlur` expose the corresponding
530
+ native synthetic events for analytics, data-refresh, and application lifecycle
531
+ policy; some backends omit `disappear` when replacing or covering a screen, so
532
+ portable visibility logic should use the accessor. The renderer's opt-in
533
+ causal telemetry records native lifecycle input as ordinary
534
+ `solid-native.event` operations.
535
+
536
+ `renderHeader(entry, index, isFocused)` runs once inside each keyed screen
537
+ owner and mounts its returned `ScreenHeader` after the route content. Header
538
+ props remain reactive when an entry is replaced without changing its stable
539
+ screen ID. The facade owns native titles, colors, back-button policy,
540
+ shadow/translucency, iOS large-title typography, safe-area top-inset handling,
541
+ and custom `back`, `left`, `right`, and `center` subviews. A subview can contain
542
+ ordinary Solid Native content and event handlers; no React wrapper or second
543
+ component owner participates. iOS headers can additionally declare native
544
+ `headerLeftBarButtonItems`/`headerRightBarButtonItems` with buttons, fixed
545
+ spacing, resource-safe icons, badges, and bounded nested menus. Only normalized
546
+ data and generated IDs cross Fabric; item callbacks stay inside the keyed Solid
547
+ owner and run when the discrete native event returns. Android uses the
548
+ cross-platform custom subview path because the upstream arrays are iOS-only.
549
+ Navigator-wide screen presentation and tab item defaults inherit through
550
+ `defaultScreenOptions`; callback-bearing header content remains explicitly
551
+ owned by `renderHeader` rather than entering an opaque option merge.
552
+
553
+ `NativeTabs` is the first deliberately experimental native-tab projection. It
554
+ retains one Solid owner per stable tab key and treats the platform's
555
+ acknowledged selection as the source of screen visibility. Controlled Solid
556
+ state can request a different key without losing the native provenance needed
557
+ to reject stale updates. The portable facade accepts one to five tabs because
558
+ Android's native `BottomNavigationView` cannot host more:
559
+
560
+ ```tsx
561
+ const tabsState = createNativeTabsState({
562
+ tabs: [
563
+ { key: "home", initialHref: "/" },
564
+ { key: "settings", initialHref: "/settings" },
565
+ ],
566
+ });
567
+
568
+ <NativeTabs
569
+ tabs={tabs}
570
+ selectedKey={tabsState.selectedKey()}
571
+ defaultScreenOptions={{ preventNativeSelection: false }}
572
+ screenOptions={(tab) => ({
573
+ title: tab.title,
574
+ icon: {
575
+ android: { type: "drawableResource", name: tab.androidDrawable },
576
+ ios: { type: "sfSymbol", name: tab.sfSymbol },
577
+ },
578
+ tabBarItemAccessibilityLabel: `${tab.title} tab`,
579
+ })}
580
+ onTabSelected={(selection) => tabsState.handleTabSelected(selection)}
581
+ >
582
+ {(tab, index, isSelected) => (
583
+ <TabScene tab={tab()} index={index()} isSelected={isSelected} />
584
+ )}
585
+ </NativeTabs>;
586
+
587
+ const settingsHistory = tabsState.history("settings");
588
+ tabsState.openDeepLink({
589
+ tabKey: "settings",
590
+ href: "/settings/account",
591
+ });
592
+ ```
593
+
594
+ Native user selection, controlled rollback, and a stale request can race. The
595
+ host therefore acknowledges every accepted selection with a monotonically
596
+ increasing provenance. `NativeTabs` keeps that acknowledgement separate from
597
+ the last JavaScript request, retries a rejected desired key from the newest
598
+ provenance, and does not echo a native selection back as a redundant request.
599
+ Replacing or reordering tab metadata with the same keys updates accessors
600
+ without recreating scenes or native roots. Signed Pixel and iPhone Release
601
+ proofs tap the real Material and UIKit tab bars and preserve a scene-local
602
+ signal across two complete tab switches. The underlying `react-native-screens`
603
+ 4.27.0 release labels its Tabs API stable and has completed Solid Native's
604
+ physical-device promotion matrix. `NativeTabs` remains experimental while its
605
+ own public contract is hardened. A keyed tab may create its own
606
+ `NativeHistory` and `NativeStack`; both proofs push a real nested stack detail,
607
+ retain it through both tab switches, then route Android system Back or an iPhone
608
+ interactive pop to that selected history without recreating the root.
609
+ Android system Back remains a discrete non-Fabric platform event. An iPhone
610
+ interactive pop instead arrives through the native `Screen.dismiss` Fabric
611
+ event; `NativeStack` retains that default-priority event across its deferred
612
+ history settlement, making the same event and route owner the exact causes of
613
+ the pop commit, mount, and frame without relabeling it as hardware Back.
614
+ `createHardwareBackHandler`
615
+ accepts either one history or an accessor that chooses a retained tab's history
616
+ at event time. It captures that target across asynchronous blocker arbitration,
617
+ so changing tabs while a decision is pending cannot complete against the wrong
618
+ stack. That keyed Settings owner also mounts its own TanStack history adapter,
619
+ Solid-backed router stores, provider, route loaders, and `TanStackNativeStack`.
620
+ Both proofs navigate through the router, render validated loader data, retain
621
+ the route component and native screen across tab switches, and return through
622
+ the platform-owned Back path. Transport-safe tab icons map compiled Android
623
+ drawable names, URI-backed Android raster sources, iOS SF Symbol/XCAsset names,
624
+ and URI-backed iOS original/template sources directly to the pinned native
625
+ screens. Sources are bounded plain data rather than React Native `require()`
626
+ values. Bounded per-platform `standardAppearance` and iOS
627
+ `scrollEdgeAppearance` objects configure native state/layout colors,
628
+ typography, Android ripple/indicator/label policy, and iOS blur/shadow policy.
629
+ The renderer validates and copies these objects; the Fabric boundary processes
630
+ their nested color values without exposing arbitrary React Native objects.
631
+
632
+ The current Pixel phase and last promoted iPhone product-composition phase cold-open a protected Settings
633
+ route, replace it with login before denied content can mount, and reuse that
634
+ exact native `Screen` for the authenticated root. They then enter an async detail
635
+ through `TanStackNativeLink` and requests a slow programmatic sheet route. The
636
+ 75 ms detail loader produces a separate pending frame beneath one
637
+ privacy-bounded `navigation.link` task. While the sheet loader is pending, a
638
+ second physical press replaces it with the final native sheet: the displaced
639
+ `navigation.programmatic` task is canceled, the winning task causes the final
640
+ normal-priority commit, and the late stale settlement is detached from both
641
+ tasks and cannot change the exact `[/, /detail, /sheet]` history. The flow
642
+ retains the tab host, nested `ScreenStack`, root `Screen`, detail `Screen`, and
643
+ scene-local Solid state. Android uses system Back around its Material sheet;
644
+ iOS uses the UIKit sheet and physically presses each native header Back control.
645
+ Both round-trip Home/Settings, restore detail, reveal the original root, and
646
+ finish with exact route, loader, native-node, `Screen`, tab-owner, and surface
647
+ lifetime accounting. This verifies auth + tabs + TanStack stack + async data +
648
+ interruption + sheet composition without introducing another navigation
649
+ coordinator. The changed iOS entrypoint is conservatively `native-integrated`
650
+ until its complete signed-device process reruns.
651
+
652
+ The Pixel product phase now also persists its opaque session through a
653
+ Solid-owned `@solidnative-dev/secure-storage` controller before navigation is
654
+ allowed to leave login. After that composed flow tears down, the runner
655
+ force-stops the process and cold-opens `/protected` in a distinct process. Its
656
+ async `beforeLoad` restores the exact Android Keystore-backed credential before
657
+ the protected component or loader may publish, with no login surface exposed.
658
+ A physical logout removes the credential, proves a subsequent read is absent,
659
+ and disposes the route, controller, tab owners, native nodes, and Fabric surface.
660
+ The gate requires exact read/write/remove causal-event counts and rejects the
661
+ credential key and value anywhere in serialized telemetry. The equivalent
662
+ two-process Keychain integration is implemented in the signed-iPhone proof but
663
+ remains pending a clean physical rerun.
664
+
665
+ `createNativeTabsState` supplies the optional higher-level state policy: one
666
+ fine-grained selected-key accessor, one retained `NativeHistory` per stable
667
+ key, atomic cross-tab live links, and one bounded versioned snapshot. Its
668
+ storage helpers serialize and coalesce both selection and child-history
669
+ updates, retain the newest snapshot after a failed native write, and retry it
670
+ on the next update or explicit flush. At cold launch an accepted URL starts its
671
+ target tab directly and discards restoration, preventing stale screens from
672
+ appearing behind Back; unhandled URLs still permit restoration. The Pixel and
673
+ iPhone Release proofs
674
+ invoke their registered URLs after storing obsolete Home-selected state through
675
+ the AsyncStorage 3.x adapter, load it with
676
+ `createNativeTabsStateFromStorage`, and require the discarded durable value to
677
+ be cleared before the resolved Settings detail mounts with no Back entry. Each
678
+ replaces that detail with the clean root, creates and pops only fresh history
679
+ through the selected-tab platform path, then flushes and decodes the final
680
+ multi-history envelope through the same native store. A preceding phase starts
681
+ cleanly, selects Settings, pushes its TanStack detail, flushes that two-entry
682
+ history, tears down the Solid surface, and stops the app process. An ordinary
683
+ no-URL launch in a distinct app process restores the selected detail, preloads
684
+ exactly the nearest prior entry,
685
+ and returns to the retained root through real Android system Back or an iPhone
686
+ left-edge interactive pop. Each runner verifies different process IDs before
687
+ performing the cold-link override phase. The iPhone proof also requires the real
688
+ two-item `UITabBar`, configured item identifiers and selection state, retained
689
+ Solid signal/route state across physical tab switches, and exact owner/surface
690
+ teardown. A preceding iPhone process directly verifies both UIKit appearance
691
+ objects and drives Home through raster, empty, SF Symbol, racing-raster
692
+ rejection, and restored-raster states. The Pixel proof loads one Home icon
693
+ through the asynchronous URI/Fresco path and one Settings icon as a compiled
694
+ drawable. Opaque React Native asset
695
+ objects, application URL parsing/storage selection, and a general preload depth
696
+ are not claimed by this surface.
697
+
698
+ Native URL sources can feed the same history without coupling this package to
699
+ React Native's singleton:
700
+
701
+ ```ts
702
+ const subscription = Linking.addEventListener(
703
+ "url",
704
+ createDeepLinkHandler(history, {
705
+ resolve: (url) => parseApplicationUrl(url),
706
+ }),
707
+ );
708
+ ```
709
+
710
+ The handler validates the event, lets the application parse or ignore the URL,
711
+ and records accepted destinations as system-originated transitions.
712
+
713
+ The React Native 0.87 backend currently realizes those semantic components
714
+ with `react-native-screens` 4.27.0, the first stable release line that explicitly
715
+ supports React Native 0.87. The repository pins and narrowly patches that exact
716
+ version for latest-request-wins tab icon ownership; see the
717
+ [compatibility strategy](../../docs/react-native-compatibility.md). This is a
718
+ backend implementation dependency, not permission for React components to own
719
+ the application tree.
720
+
721
+ The Pixel 9a has passed the exact 4.27.0 six-process stack-restoration suite
722
+ and the native-tab restoration, Material appearance, and asynchronous image
723
+ ownership suite. The signed iPhone passes its corresponding native-tab
724
+ restoration, UIKit appearance, asynchronous image-ownership suite and a focused
725
+ auth/link/interruption/stack/sheet composition process. The exercised Android
726
+ and iOS screens surfaces are device-verified.
727
+
728
+ `@solidnative-dev/navigation` declares 4.27.0 as an exact peer and ships both the
729
+ reviewed patch and a machine-readable backend contract. The supported CLI
730
+ workflow installs both exact packages and materializes the immutable patch in
731
+ the application:
732
+
733
+ ```sh
734
+ solid-native add navigation
735
+ ```
736
+
737
+ The command verifies the shipped contract and patch digest, refuses to replace
738
+ a different application-owned file or mapping, merges the following
739
+ `pnpm-workspace.yaml` configuration, reinstalls the dependency graph, and
740
+ verifies every reviewed patched native file before reporting success:
741
+
742
+ ```yaml
743
+ patchedDependencies:
744
+ react-native-screens@4.27.0: patches/react-native-screens@4.27.0.patch
745
+ ```
746
+
747
+ Exact declarations that already resolve through a private registry or local
748
+ packed-artifact override are supported idempotently. Use
749
+ `solid-native add navigation --dry-run --json` to inspect the complete package,
750
+ patch, and reinstall plan without changing the application.
751
+
752
+ `solid-native doctor` reads the exported backend contract, verifies the patch
753
+ asset, exact React Native/screens declarations, and the SHA-256 identity of all
754
+ three installed patched native files. Merely installing the right upstream
755
+ version is therefore insufficient to produce a passing backend check.
756
+
757
+ Process-restoration snapshots use a versioned, bounded JSON envelope:
758
+
759
+ ```ts
760
+ const persisted = serializeNativeHistorySnapshot(history.snapshot);
761
+ const restored = new NativeHistory({
762
+ snapshot: deserializeNativeHistorySnapshot(persisted),
763
+ });
764
+ ```
765
+
766
+ Deserialization validates the complete shape and transport-safe state before a
767
+ history instance is created. The current limits are 512 stack entries and
768
+ 1,048,576 serialized characters. The application shell can reconcile its
769
+ untrusted storage value with the platform's initial URL before first mount:
770
+
771
+ ```ts
772
+ const launch = await createNativeHistoryFromStorage({
773
+ storage,
774
+ storageKey: "navigation",
775
+ initialURL: await NativePlatform.getInitialURL(),
776
+ resolveDeepLink: (url) => parseApplicationUrl(url),
777
+ });
778
+ const scrollLaunch = await createNativeScrollRestorationFromStorage(
779
+ launch.history,
780
+ {
781
+ storage,
782
+ storageKey: "navigation-scroll",
783
+ historySource: launch.source,
784
+ },
785
+ );
786
+
787
+ const persistence = createNativeHistoryPersistence(launch.history, storage, {
788
+ storageKey: "navigation",
789
+ });
790
+ const scrollPersistence = createNativeScrollRestorationPersistence(
791
+ scrollLaunch.restoration,
792
+ storage,
793
+ { storageKey: "navigation-scroll" },
794
+ );
795
+
796
+ const stack = (
797
+ <TanStackNativeStack
798
+ history={launch.history}
799
+ scrollRestoration={scrollLaunch.restoration}
800
+ renderUnresolved={renderUnresolved}
801
+ />
802
+ );
803
+ await Promise.all([persistence.flush(), scrollPersistence.flush()]);
804
+ ```
805
+
806
+ An accepted initial URL starts a fresh stack, valid storage preserves its
807
+ stable screen IDs when no URL wins, and corrupt storage is surfaced through
808
+ `launch.restorationError` while the app falls back to its safe initial route.
809
+ Corrupt state considered for restoration is removed. A valid snapshot
810
+ superseded by an accepted URL is also removed before launch returns, preventing
811
+ a crash before persistence setup from resurrecting the discarded stack. The
812
+ same serialized-size bound is enforced against candidate in-memory history
813
+ before push, replace, reset, or deep-link assignment, so oversized application
814
+ state cannot partially mutate navigation and then fail inside a persistence
815
+ subscriber.
816
+ Ongoing writes are serialized and coalesce behind a slow native operation,
817
+ while `flush()` exposes their durability or failure. A failed newest history,
818
+ tabs, or scroll snapshot remains pending without entering a hot retry loop; the
819
+ next state change or explicit `flush()` retries it, and newer state still
820
+ supersedes an older failed value. The observer disposes with its Solid owner.
821
+ Scroll snapshots use a separate versioned envelope, retain at most 512 history
822
+ entries and 32 named containers per entry, and are capped at 1,048,576
823
+ serialized characters. Live captures maintain that complete bound with
824
+ incremental per-container accounting, so an oversized capture is rejected
825
+ before mutation without serializing the full registry on every native scroll
826
+ event. Keeping the keys separate lets applications discard high-volume
827
+ presentation state independently while the required `historySource` gate
828
+ prevents it from crossing a fresh navigation launch.
829
+ An injected `NativeScrollRestoration` remains application-owned; dispose its
830
+ storage observer and controller with the application shell after final flush.
831
+ Selecting and configuring the actual platform store remains explicit
832
+ application-shell policy; `@solidnative-dev/storage/async-storage-3` supplies the
833
+ first validated wrapper-free AsyncStorage adapter for an injected generated
834
+ native module.
835
+
836
+ The integration pins `@tanstack/history` 1.162.1 and
837
+ `@tanstack/router-core` 1.171.26. The evaluated `@tanstack/solid-router`
838
+ 1.170.29 release still declares `solid-js ^1.9.10`, so its concrete component
839
+ binding remains outside this Solid 2 RC workspace. Router core now exposes a
840
+ framework store extension point; the native binding uses that supported seam
841
+ for real typed matching, pending loads, loader data, and error match state.
842
+ Solid-owned route presentation must not depend on a DOM provider.
843
+
844
+ Implemented now:
845
+
846
+ - A contract-checked TanStack `RouterHistory` adapter with restoration-safe
847
+ state indices/keys, forward traversal, programmatic blockers, and exact-once
848
+ native/router notification flow
849
+ - A Solid 2-native TanStack Router core using fine-grained signals, derived
850
+ memos, and `flush`-atomic match publication
851
+ - An owner-bound native router provider and leaf route-state view covering
852
+ initial/pending load, success, loader error with retry, global not-found, and
853
+ teardown without a DOM
854
+ - A registered-router typed `TanStackNativeLink` backed by the real native
855
+ `Pressable`, with fine-grained active/pending/transition state, duplicate
856
+ navigation suppression, touch-intent/render preloading, reactive native
857
+ props, and accessible current-route semantics
858
+ - A typed programmatic navigation hook with route-local relative resolution,
859
+ plus native-history-safe TanStack route-entry redirects for authentication
860
+ and onboarding guards
861
+ - Nested native route components/outlets, route-local pending/error/not-found
862
+ presentation, Solid component-error recovery, and registered-router typed
863
+ match/loader selectors
864
+ - A `TanStackNativeStack` projection that freezes each inactive screen's last
865
+ settled match tree while preserving keyed Solid/native identity
866
+ - A reactive mounted-route-tree budget that disposes older Solid match owners
867
+ while preserving keyed native screen containers, navigation history, and
868
+ settled router snapshots
869
+ - A TanStack-native `ScrollView` that retains named offsets per stable history
870
+ entry and restores exactly once when parking remounts the native container
871
+ - Shared blocker arbitration for Android hardware Back and prevented iOS
872
+ native-dismiss attempts, with errors failing closed
873
+ - Stable, serializable native history
874
+ - Application push, replace, pop, reset, and system deep-link transitions
875
+ - Two-phase completion or cancellation of platform-initiated back transitions
876
+ - Native stack presentation with keyed Solid screen ownership
877
+ - Standalone `NativeModalStack` routing with keyed owner retention through
878
+ platform dismissal, restoration, and async close blockers
879
+ - Native-event-derived per-screen focus accessors and focus/blur callbacks
880
+ - Owner-safe focus scopes for opt-in background-work suspension while retained
881
+ - Abort-aware focus tasks for canceling asynchronous screen work on blur or
882
+ disposal without leaking stale failures
883
+ - Opt-in transition-complete accessibility focus without React refs or tags
884
+ - Basic native stack titles, back-button policy, and iOS large-title styling
885
+ - Experimental native tabs with keyed Solid owners, controlled provenance
886
+ reconciliation, selection/lifecycle events, transport-safe appearance,
887
+ tab-aware history/restoration, and physical Pixel/iPhone proofs. The reviewed
888
+ appearance gates back device-verified `RNSTabsHostAndroid`,
889
+ `RNSTabsScreenAndroid`, `RNSTabsHostIOS`, and `RNSTabsScreenIOS` catalog
890
+ claims.
891
+ - iOS interactive dismiss and Android system-back reconciliation
892
+ - A framework-neutral `createHardwareBackHandler` callback for Android's native
893
+ Back event source
894
+ - A framework-neutral `createDeepLinkHandler` callback for native URL event
895
+ sources, physically verified through registered iOS and Android app links
896
+ - An owner-bound `createNativeNavigationBindings` helper that subscribes both
897
+ platform sources, enters the causal protocol with privacy-safe static event
898
+ names and appropriate priorities, and removes them during Solid cleanup
899
+ - Deterministic cold-start precedence and corrupt-restoration fallback through
900
+ `createNativeHistoryFromLaunch`
901
+ - Explicit `createNativeHistoryFromStorage` restoration plus owner-bound,
902
+ ordered `createNativeHistoryPersistence` with a flush boundary
903
+
904
+ Still to provide:
905
+
906
+ - Promote the stable upstream native-tab pin through Solid Native's complete
907
+ unlocked-device matrix, then graduate the local experimental API
908
+ - More aggressive hidden-screen freezing only if adopter workloads show
909
+ focus-scoped native work is insufficient
910
+
911
+ `createNativeNavigationBindings` names Android hardware Back as
912
+ `platform.hardware-back.press` with discrete priority and live URLs as
913
+ `platform.url.open` with default priority. Callback payloads never enter
914
+ telemetry. A physical Pixel Release run proves a blocker-mediated Back through
915
+ its exact user-blocking commit, mount, and frame, and proves a running-process
916
+ URL through its normal-priority commit and newly focused screen output. When a
917
+ blocker is active, the binding preserves `BackHandler`'s synchronous consumed
918
+ boolean and uses a delivery-scoped retention to re-enter only around the later
919
+ allow/deny settlement. The Pixel proof exercises a denied first Back and an
920
+ allowed second Back; only the allowed event causes the pop commit.
921
+
922
+ See [the navigation design](../../docs/navigation.md) and
923
+ [ADR 0002](../../docs/adr/0002-tanstack-router.md).