feat(react-native-example): add in-tree example app for @knocklabs/react-native#976
feat(react-native-example): add in-tree example app for @knocklabs/react-native#976
Conversation
…arn workspace Adds a bare React Native 0.83.4 app at examples/react-native-example, wired into the monorepo via yarn workspaces. Metro is configured for workspace hoisting (watchFolders + nodeModulesPaths + disableHierarchicalLookup) so the app resolves dependencies from the root node_modules. Versions are aligned with the rest of the repo (react ^19.2.5, babel/runtime ^7.28.6, etc.) per manypkg. Drops the create-app boilerplate (jest tests, NewAppScreen, the default README) since this app uses vitest at the root and doesn't need its own tests. Prettier is wired to the shared @knocklabs/prettier-config so the source style matches the rest of the monorepo. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…d README Wires up React Navigation v7 native stack with six screens that match the parity spec: Startup, SignIn, Main, MessageCompose, Preferences, TenantSwitcher. Each screen is a real early-stage render that shows the eventual purpose of the screen (form fields for sign-in, channel toggles for preferences, tenant list, etc.) — not a "coming soon" placeholder. Runtime configuration is hardcoded in src/config.ts behind an AppConfig type with TODO markers per field, matching the pattern used by the Android and iOS demos. Phase 2 will wire the screens to @knocklabs/react-native; Phase 1 keeps the SDK out so the scaffold can be reviewed independently. README mirrors the expo-example README shape and disambiguates the two: this one demonstrates @knocklabs/react-native in a bare RN context, expo-example demonstrates @knocklabs/expo on Expo-managed. KNO-12856 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
…roid/iOS demos Adds @knocklabs/react-native as a workspace dependency along with the required peer (react-native-gesture-handler). Wraps the authed stack in KnockProvider + KnockPushNotificationProvider + KnockFeedProvider, gated by a small AuthContext that lifts user identity and tenant scope to the app root. Pre-auth screens (Startup, SignIn) live in a separate stack so the navigator structure makes the auth boundary obvious. Realigns each screen against the Android (knocklabs/knock-android/knock-example-app) and iOS (knocklabs/ios-example-app) demos for parity: - Config exports six flat KNOCK_* constants matching Android's Utils.kt shape, plus KNOCK_TENANT_A and KNOCK_TENANT_B for the iOS-style tenant switcher. - Main embeds the prebuilt <NotificationFeed /> component so the in-app feed renders in real time. - Compose shows the workflow trigger form and clears the field on send. The server-side trigger pattern is documented inline; clients can't trigger workflows directly because that requires the secret API key. - Preferences uses usePreferences for live read/write of channel-type preferences and hosts the sign-out action. - TenantSwitcher offers None / Tenant A / Tenant B; selecting one updates auth state and re-mounts KnockFeedProvider with the new tenant scope. Knock packages must be built once (`yarn build:packages`) before type-checking or bundling, since the SDK exposes types from dist/. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…olinking @knocklabs/react-native pulls in react-native-svg and react-native-get-random-values as runtime deps. In a yarn workspace, those land in the hoisted root node_modules, and bare RN's iOS autolinking only walks the host app's direct dependencies — so the transitive native modules weren't getting linked into the Pods project. Declaring them explicitly here makes autolinking pick them up alongside react-native-gesture-handler and react-native-screens. Also includes the regenerated Podfile.lock, Pods-touched Xcode project changes, and the .xcworkspace produced by `pod install`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a8a7d4d. Configure here.
|
|
||
| export default function PreferencesScreen() { | ||
| const { signOut } = useAuth(); | ||
| const { preferences, setPreferences, isLoading } = usePreferences(); |
There was a problem hiding this comment.
Preferences not scoped to active tenant
Medium Severity
usePreferences() is called without passing the active tenant, so preferences are always fetched and set globally even when a tenant is selected. The README claims the tenant switcher scopes both the feed and preferences, and the usePreferences hook accepts an options parameter with a tenant field. The current auth.tenant from useAuth() is available but never forwarded, causing a mismatch between the feed (which is tenant-scoped via defaultFeedOptions) and the preferences screen.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit a8a7d4d. Configure here.
| apiKey={KNOCK_API_KEY} | ||
| host={KNOCK_HOSTNAME} | ||
| user={{ id: auth.userId }} | ||
| logLevel="debug" |
There was a problem hiding this comment.
Debug log level hardcoded in provider
Low Severity
KnockProvider has logLevel="debug" hardcoded, which will produce verbose console output for anyone running the example. This looks like a development-time setting that was left in. Example apps are the first thing new users clone, and noisy debug logs can be confusing.
Reviewed by Cursor Bugbot for commit a8a7d4d. Configure here.


Description
Every other client SDK ships with an in-tree example app. React Native didn't — the previous one was removed in #629 and never replaced. That gap was the structural reason developers kept getting stuck on RN setup (KNO-11408) and blocked downstream docs work that needed something to point at. This PR adds a new example at
examples/react-native-example/with the same six screens as the Android (knocklabs/knock-android/knock-example-app/) and iOS (knocklabs/ios-example-app) demos: Startup, Sign in, Main (with the prebuiltNotificationFeed), Compose, Preferences, Tenant switcher.Bare RN is still the right target for
@knocklabs/react-native's audience even though Expo is the React Native default —expo-examplecovers Expo, this covers bare. The "doesn't run anymore" concern from #629 is real; CI on this workspace is a fast follow-up so it doesn't bit-rot the same way. Docs change inknocklabs/docsto follow.expo-exampleand passmanypkg.react-native-svgandreact-native-get-random-valuesare direct deps because bare RN's iOS autolinking won't pick up transitive native modules.Checklist
Linear: KNO-12856