This file provides guidance to AI agents (Cursor, Claude, GitHub Copilot Chat, etc.) when working in this repository. Paths in this guide are relative to the repository root (e.g. BRIDGING.md, ios/, src/).
It is designed so that customers who clone or fork this repository can safely let AI agents help them extend or customize the React Native SDK, especially when bridging new native APIs.
If you are an AI assistant reading this file, you MUST follow the rules in this document when changing code in this repo.
- This repo is the Nutrient React Native SDK package:
- Public npm package:
@nutrient-sdk/react-native - Public GitHub repo:
PSPDFKit/react-native
- Public npm package:
- It exposes native iOS and Android SDKs to React Native via:
- Legacy Architecture (bridge-based)
- New Architecture (Fabric + TurboModules)
Whenever you add or change a native-backed API that is visible from TypeScript/JavaScript, you MUST follow the bridging recipe in:
BRIDGING.md
Use BRIDGING.md (and the corresponding skills/react-native-bridge-recipe/SKILL.md if your tool supports skills) whenever:
- You touch native-backed APIs exposed to JS/TS, including:
index.jspublic methods that call into native codesrc/specs/(TurboModule/Fabric specs)android/src/**orios/**native implementations that are used from JS
- The user asks to:
- "Bridge" an iOS/Android feature to React Native
- Add/change a TurboModule or Fabric component
- Add/change a method on
PDFDocument,NutrientView, or any other class that calls into native code
If you are not sure whether a change is native-backed, assume it is and follow BRIDGING.md.
These are summaries; the full source of truth is BRIDGING.md.
-
Dual architecture support is mandatory
- Every public API that talks to native MUST work in both:
- Legacy Architecture (bridge-based:
NativeModules,UIManager,requireNativeComponent) - New Architecture (Fabric + TurboModules)
- Legacy Architecture (bridge-based:
- Do not add an API that works only on one architecture.
- Every public API that talks to native MUST work in both:
-
Single public surface
- Callers use only the public API (usually
index.jsand the exported classes/components). - The public API branches on
isNewArchitectureEnabled()and then delegates to:- TurboModule / Fabric implementation (New Architecture), or
- Legacy bridge implementation (
NativeModules,UIManager, etc.).
- Do not expose TurboModules or Legacy-only modules directly to consumers.
- Callers use only the public API (usually
-
Spec‑first for New Architecture
- All New Architecture APIs must be declared in
src/specs/and implemented under:- Android:
android/src/newarch/java/ - iOS:
ios/Turbo/and/orios/Fabric/
- Android:
- All New Architecture APIs must be declared in
src/- TypeScript source, including:
annotations/,configuration/,document/,forms/,measurements/notification-center/,toolbar/specs/(TurboModule/Fabric specs)
- TypeScript source, including:
lib/- Compiled JavaScript from
src/
- Compiled JavaScript from
types/- Generated
.d.tsdefinitions
- Generated
android/src/main/java/: Legacy implementationsrc/newarch/java/: New Architecture implementation
ios/Common/,Converters/,Fabric/,Turbo/,Helpers/
samples/Catalog/- Example app used for development and testing
-
Generally safe (no native changes):
- Pure TypeScript changes under
src/that do not call native - Documentation in
README.md,CHANGELOG.md, comments - Sample app JS/TS changes in
samples/Catalogthat do not alter native APIs
- Pure TypeScript changes under
-
Risky (must follow
BRIDGING.md):- Any changes to:
index.jsmethods that call native codesrc/specs/**android/src/**orios/**that are called from JSPDFDocumentmethods that interact with the document on nativeNutrientViewprops, commands, or events
- Any changes to:
If in doubt, treat the change as native-backed and follow the bridging recipe.
When implementing or modifying native-backed APIs:
-
iOS
- LLMS guide index:
https://www.nutrient.io/guides/ios/llms.txt - Objective‑C API reference:
https://www.nutrient.io/api/ios/documentation/overview?language=objc - Swift API reference:
https://www.nutrient.io/api/ios/documentation/overview
- LLMS guide index:
-
Android
- LLMS guide index:
https://www.nutrient.io/guides/android/llms.txt - Kotlin/Java API reference:
https://www.nutrient.io/api/android/
- LLMS guide index:
You should scan all relevant APIs and guides before choosing which native API to use, rather than stopping at the first plausible match.
- For non-trivial changes, especially native-backed ones, you should:
- Run the Catalog app on iOS and/or Android
- Run unit tests (
npm test) and linters (npm run lint) when applicable - For native bridge changes, follow the build and validation steps in
BRIDGING.md
This ensures that custom bridges and extensions added by customers remain robust across both architectures.