Repository navigation
feat(lynx): deep linking - #9
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 9016738 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
React Navigation splits linking in two: `@react-navigation/core` turns a path into navigation state and back, and the platform package answers which URL launched the app and how later ones arrive. Only those two were missing on Lynx, so core is untouched. A card is not the process that receives the URL - the host is - so the host hands it over through `initData.__navigation` for a cold start and a `reactnavigation.url` global event for later ones. The event name is namespaced because `GlobalEventEmitter` is one namespace shared with the host, and initData carries a nonce because it is state, not an event: without one, the same route twice would be dropped. Unlike React Native there is nothing to await - initData is already in hand when the card starts - so the first render lands on the right route rather than on the fallback. `extractPathFromURL` is taken from `@react-navigation/native` unchanged, along with its 15 test cases, so prefix stripping behaves identically.
upupming
force-pushed
the
feat/linking
branch
from
September 7, 2026 11:42
6f60e09 to
9016738
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds deep linking to
@react-navigation/lynx.What it does
React Navigation splits linking in two.
@react-navigation/coreturns a path into navigation state and back —getStateFromPath,getPathFromState,getActionFromState— and none of it touches a platform. The platform package answers two questions, and both are already injectable asgetInitialURL/subscribe:So this PR only fills those in. Everything downstream is reused untouched.
How the host hands a route over
A Lynx card is not the process that receives the link — the host app is — so the host has to pass it along. Two ways, both supported:
initData.__navigation— set atloadTemplate, updated later viaupdateMetaData. Read synchronously at startup, so unlike React Native's promise-basedLinking.getInitialURL()there is nothing to await and the first render already lands on the right route.initDatais state rather than an event, so navigating twice to the same route would leave the value untouched and be dropped. Hencenonce:A
reactnavigation.urlglobal event — for hosts that would rather push than update data.The name is namespaced deliberately. React Native can afford the bare
urlbecauseRCTLinkingManageris its own event emitter and subscription goes throughLinking.addEventListener, so the name is scoped to that module. Lynx'sGlobalEventEmitteris a single namespace shared by the whole card and its host, whereurlis short enough to collide with something unrelated. The bareurlevent is still accepted, so a host already speaking React Native's protocol needs no second code path.Usage
Routes that start with
/skip prefix stripping entirely, so a host that hands over a path rather than a full schema needs noprefixesat all.One ReactLynx difference worth flagging
The container reads its imperative handle from
NavigationContainerRefContextinstead of a ref. Under ReactLynx a ref onBaseNavigationContaineryields the Preact component instance —props,render,base, … — not the handle, soref.current.getRootState()throws. Reading it from inside the tree sidesteps the difference.Verification
11 unit tests cover reading the launch route, nonce deduping, both event names, unsubscribe, and a host with no emitter.
Verified end to end on a Pixel 4 XL through
LynxExample:-e route "/depth/3"lands on Level 3, withparsehaving turned"3"into a number/eventsnavigates to itThe example app in
examples/stacknow passes a linking config, andLynxExample'sDebugActivityreads arouteintent extra and forwards it both ways — that lives in thelynx-screensrepo and is a separate PR.