react-native-cross-shortcuts
v0.1.1
Published
One config, all platforms. Generate iOS App Intents + Siri Shortcuts, Android App Shortcuts + Google Assistant App Actions for any React Native app.
Maintainers
Readme
react-native-cross-shortcuts
One config, all platforms. Generate iOS App Intents + Siri Shortcuts, Android App Shortcuts + Google Assistant App Actions for any React Native app.
What you get from a single shortcuts.config.json
| Surface | Result |
|---|---|
| iOS Spotlight | App actions appear in Spotlight without users adding them |
| Siri | "Hey Siri, " launches the right screen |
| Action Button (iPhone 15 Pro+) | Bindable to any of your shortcuts |
| Shortcuts app | All actions auto-registered via AppShortcutsProvider |
| iOS Home Screen | Long-press app icon → quick actions |
| Android Home Screen | Long-press app icon → quick actions |
| Google Assistant | "Hey Google, " launches the right screen |
All actions land in your existing React Native deep-link handler (Linking API).
Install
npm install react-native-cross-shortcuts
# Optional, only if you also want iOS NSUserActivity donations:
npm install react-native-siri-shortcutConfigure
Create shortcuts.config.json at your project root:
{
"scheme": "myapp",
"appName": "My App",
"ios": {
"xcodeprojPath": "ios/MyApp.xcodeproj",
"targetName": "MyApp",
"groupName": "MyApp",
"swiftOutputPath": "ios/MyApp/AppIntents.generated.swift",
"infoPlistPath": "ios/MyApp/Info.plist",
"minIosVersion": "16.0",
"shortcutTileColor": "purple"
},
"android": {
"modulePath": "android/app",
"applicationId": "com.myorg.myapp"
},
"shortcuts": [
{
"id": "open-feed",
"shortLabel": "Open Feed",
"longLabel": "Jump straight into your feed",
"systemImage": "list.bullet",
"deepLink": "/feed",
"siriPhrases": ["Open my feed in ${appName}"],
"assistantBII": "actions.intent.OPEN_APP_FEATURE"
},
{
"id": "search",
"shortLabel": "Search",
"longLabel": "Search anything in My App",
"systemImage": "magnifyingglass",
"deepLink": "/search",
"siriPhrases": ["Search with ${appName}"],
"parameter": {
"name": "query",
"title": "Search query",
"description": "What would you like to search for?",
"paramQuery": "q"
},
"assistantBII": "actions.intent.GET_THING"
}
]
}Run codegen
npx cross-shortcuts syncThe CLI:
- Generates
ios/<App>/AppIntents.generated.swiftwith oneAppIntentper shortcut and a singleAppShortcutsProvider. - Patches
Info.plistwith the matchingNSUserActivityTypesentries. - Injects the generated Swift file into your
.xcodeprojvia the bundled Ruby script (xcodeprojgem — comes with CocoaPods). - Generates
android/app/src/main/res/xml/shortcuts.xmlandactions.xml. - Patches
AndroidManifest.xmlwith the custom-scheme intent filter and the<meta-data>references. - Adds the per-shortcut label
<string>resources tostrings.xml(inside an idempotent<!-- BEGIN cross-shortcuts -->block).
Wire it up at runtime
import { addShortcutListener, donateShortcut } from 'react-native-cross-shortcuts';
useEffect(() => {
const unsub = addShortcutListener({ scheme: 'myapp' }, (event) => {
// event.id === 'feed' | 'search' | ...
// event.params === { q: 'gita' } when launched with ?q=gita
navigateTo(event.id, event.params);
});
return unsub;
}, []);
// Donate on success — teaches the system to suggest this shortcut.
donateShortcut({
applicationId: 'com.myorg.myapp',
shortcutId: 'open-feed',
title: 'Open Feed',
invocationPhrase: 'Open my feed',
});How re-runs behave
The CLI is idempotent. Re-run it whenever you edit shortcuts.config.json:
- Swift file is regenerated wholesale (and re-injected into the project file if missing).
Info.plistNSUserActivityTypesarray is replaced (not duplicated).AndroidManifest.xmlpatches detect existing entries and skip.strings.xmlblock is delimited and replaced atomically.
Limitations / roadmap
- Dynamic Android shortcuts and iOS NSUserActivity-only fallback to be added.
- iOS
EntityQuery-style parameter resolution not yet generated; current parameter support is a free-form string. - We don't add
xcodeprojas a dependency — assumes CocoaPods is installed (already required by RN). If it isn't:gem install xcodeproj.
License
MIT
