feat(ui): host-owned back stack embedding for the user profile - #836
feat(ui): host-owned back stack embedding for the user profile#836mikepitre wants to merge 4 commits into
Conversation
Hosts that embed UserProfileView or AuthView inside their own navigation chrome (e.g. the Expo SDK, or apps with their own top app bar) can now pass the new optional embeddedNavigation parameter. When provided, Clerk's top app bars are hidden and the host observes stack depth and drives pop()/popToRoot() through the ClerkEmbeddedNavigation handle. Behavior is unchanged when the parameter is omitted. Named embedded rather than hosted because hosted already refers to Clerk's hosted web pages in the mobile SDKs. Affects the ui module only. Obtaining a ClerkEmbeddedNavigation requires opting in to the new FrameworkIntegrationApi marker (com.clerk.api), the Android counterpart of the iOS SDK's @_spi(FrameworkIntegration) surface. Components accept the parameter without opt-in; only handle creation is gated.
EmbeddedNavigationEffects now clears the pop handler only when it still owns it, so a component leaving composition after a successor registered cannot tear the successor down, and resets depth to 0 on teardown so the handle no longer reports canGoBack while pop() would be a no-op. Affects the ui module only.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Embedded pop commands mutated the back stack directly, bypassing AuthState.navigateBack's suppression of the in-progress attempt resume, so popping a factor screen bounced straight back to it. EmbeddedNavigationEffects now accepts pop overrides and AuthView routes commands through AuthState. Affects the ui module only.
Adds ClerkUserProfileRoute and EntryProviderScope.clerkUserProfileEntries so hosts can render Clerk's profile screens inside their own NavDisplay: the host owns the back stack, transitions, and predictive back, and Clerk pushes and removes only its own keys. This is the Android counterpart of the iOS SDK's public UserProfileView(navigationPath:) embedding. The profile root shows a back arrow instead of a dismiss affordance in this mode, account deletion exits only the profile's segment of the stack, and navigation3-runtime becomes an api dependency since the new surface exposes its types. Includes a runnable demo in the prebuilt-ui sample. Affects the ui module and the prebuilt-ui sample.
9d85a6b to
5a7f419
Compare
|
Parking this as a draft deliberately: the Expo integration doesn't use host-stack entries (it drives the profile through the FrameworkIntegrationApi-gated handle), so this public API — and the AuthView counterpart it still needs — can wait for a proper design review while the Expo-critical PRs ship. Written by Claude Code |
bf9db79 to
8766d5f
Compare
Problem
The embedded-navigation handle (#798) lets a host hide Clerk's top bars and drive the profile's internal stack, but the profile still renders its own navigation container. Native Compose apps should be able to put Clerk's screens inside their own
NavDisplay— the Android counterpart of the iOS SDK's publicUserProfileView(navigationPath:)embedding — so the host owns transitions, predictive back, and the stack itself.What this adds
A public
ClerkUserProfileRoutekey andEntryProviderScope.clerkUserProfileEntries(backStack):rememberNavBackStackvia nav3's reflection-based NavKey serialization.ClerkUserProfileRouteand never touch host entries (UserProfileState.clearBackStackgains a scoped strategy for this).navigation3-runtimemoves fromimplementationtoapisince the new surface exposes its types.UserProfileViewshares the same entry registrations (extracteduserProfileChildEntries) and is unchanged in behavior.Verified end to end on an emulator via the new demo in the prebuilt-ui sample: host home → profile root → Security inside one host-owned
NavDisplay, with hardware back unwinding one screen at a time and landing on the intact host screen.Follow-up (intentionally not in this PR): the same treatment for
AuthView. ItsAuthStatecarries cross-screen form state, so per-entry providers would break it — the shared-scope design for that is coming separately.Modules
source/uiand theprebuilt-uisample.🤖 Generated with Claude Code
Note
Add host-owned back stack embedding for the Clerk user profile in NavDisplay
clerkUserProfileEntriesextension onEntryProviderScopeso apps can register Clerk's user profile destinations inside their ownNavDisplayand back stack, with Clerk only removing its own keys on exit.ClerkUserProfileRouteas a serializableNavKeythat hosts push onto theirNavBackStackto open the profile.exitClerkUserProfileandpopToClerkUserProfileRootback stack helpers and aHostEntryChromewrapper that applies Clerk's theme and providers to hosted entries.userProfileChildEntriesout ofuserProfileEntriesso child destinations are shared between self-contained and host-owned setups without changing existing behavior.HostStackProfileSamplecomposable in the prebuilt-ui sample app demonstrating the host-owned flow via a full-screen dialog.libs.androidx.navigation3.runtimeis now exposed asapifrom thesource/uimodule, making it transitive for library consumers.Macroscope summarized 5a7f419.