@avasapp/react-native-app-intents helps React Native apps define type-safe intents once, generate native
App Intents/App Shortcuts files, and route launched intents back into JavaScript.
npm install @avasapp/react-native-app-intents
For iOS bare React Native apps, install pods after adding the package:
npx pod-install
Create intent files anywhere matched by your config, for example src/orders.intents.ts:
import { defineEntity, defineIntent, p } from "@avasapp/react-native-app-intents";
export const Order = defineEntity({
id: "Order",
title: "Order",
inventory: [{ id: 1, number: "1234", customer: "Taylor" }],
schema: p.object({
id: p.int(),
number: p.string(),
customer: p.string(),
}),
identifier: (order) => String(order.id),
displayRepresentation: (order) => ({
title: `Order #${order.number}`,
subtitle: order.customer,
image: { systemName: "bag" },
}),
});
export const openOrder = defineIntent({
id: "openOrder",
title: "Open Order",
description: "Open a specific order.",
phrases: ["Open order ${orderNumber} in ${.applicationName}"],
params: {
orderNumber: p.string({
title: "Order number",
default: "1234",
requestValueDialog: "What's the order number?",
}),
},
surfaces: {
spotlight: true,
appShortcut: {
icon: {
androidResourceName: "@mipmap/ic_launcher_round",
systemName: "shippingbox",
},
},
},
android: {
appAction: {
capability: "actions.intent.GET_ORDER",
},
},
ios: {
appIntent: {},
},
behavior: { opensAppToForeground: true },
});
export const openSavedOrder = defineIntent({
id: "openSavedOrder",
title: "Open Saved Order",
phrases: ["Open ${order} in ${.applicationName}"],
params: {
order: p.entity(Order, {
androidBiiParam: "order",
title: "Order",
default: { id: 1, number: "1234", customer: "Taylor" },
}),
},
surfaces: {
spotlight: true,
appShortcut: true,
},
android: {
appAction: {
capability: "actions.intent.GET_ORDER",
},
},
ios: {
appIntent: {},
},
});
Generated app-intents URLs use the configured scheme with the reserved
app-intents host, for example myapp://app-intents/openOrder?.... If your
app also uses myapp:// for normal deep links, keep routing those links by host
or path in React Native Linking; this library should only claim the
app-intents host.
Create app-intents.config.ts at your app root:
import { defineAppIntentsConfig } from "@avasapp/react-native-app-intents/codegen";
export default defineAppIntentsConfig({
intents: ["src/**/*.intents.ts"],
scheme: "myapp",
ios: {
output: "ios/MyApp/AppShortcuts.swift",
appGroupIdentifier: "group.com.example.myapp",
appShortcutsProviderName: "MyAppShortcuts",
bundleIdentifier: "com.example.myapp",
siriUsageDescription: "Used to let Siri run app actions.",
},
android: {
manifest: "android/app/src/main/AndroidManifest.xml",
shortcutsOutput: "android/app/src/main/res/xml/app_shortcuts.xml",
packageName: "com.example.myapp",
},
types: { output: "src/generated/app-intents.d.ts" },
});
Run codegen:
npx app-intents generate
Use --check in CI to fail when generated files are stale:
npx app-intents generate --check
Use the package root as the Expo config plugin. The plugin auto-loads
app-intents.config.ts from your app root, so Expo prebuild and the CLI share
one source of truth:
{
"expo": {
"plugins": ["@avasapp/react-native-app-intents"]
}
}
If your config lives elsewhere, pass configPath:
{
"expo": {
"plugins": [["@avasapp/react-native-app-intents", { "configPath": "./config/app-intents.ts" }]]
}
}
Expo mode honors configured ios.output, android.manifest,
android.shortcutsOutput, and android.shortcutsStringsOutput paths relative to
the app root. An ios.output without an ios/ prefix is written under the
generated iOS project folder.
Use Expo’s expo-asset config plugin when you want a custom Android shortcut
icon from an image file instead of a built-in launcher resource. The plugin links
the file into the native project during prebuild, and the file name becomes the
Android resource name.
{
"expo": {
"plugins": [
["expo-asset", { "assets": ["./assets/shortcuts/open_order.png"] }],
"@avasapp/react-native-app-intents"
]
}
}
Then reference that asset from your intent definition or dynamic shortcut:
export const openOrder = defineIntent({
id: "openOrder",
title: "Open Order",
phrases: ["Open order ${orderNumber} in ${.applicationName}"],
params: {
orderNumber: p.string({ default: "1234" }),
},
surfaces: {
appShortcut: {
icon: {
androidResourceName: "@drawable/open_order",
systemName: "shippingbox",
},
},
},
});
await appIntents.updateDynamicShortcuts([
{
icon: {
androidResourceName: "@drawable/open_order",
iosTemplateImageName: "open_order",
systemName: "shippingbox",
},
intent: openOrder,
params: { orderNumber: "1234" },
shortTitle: "Open order #1234",
},
]);
Notes:
expo-asset uses the file name as the native resource name, so
assets/shortcuts/open_order.png becomes @drawable/open_order.npx expo prebuild after adding, removing, or renaming shortcut icon
files.iosTemplateImageName: "open_order" (no file
extension) to point at the bundled asset by name.systemName; Expo-bundled PNG assets are not used
there.Add the package as an Expo config plugin:
{
"expo": {
"plugins": [
[
"@avasapp/react-native-app-intents",
{
"intents": ["src/**/*.intents.ts"],
"scheme": "myapp",
"ios": {
"appGroupIdentifier": "group.com.example.myapp",
"siriUsageDescription": "Used to let Siri run app actions."
}
}
]
]
}
}
Then run prebuild:
npx expo prebuild
The plugin currently:
Info.plist for the URL scheme and optional Siri/app-group settingsios.appGroupIdentifier is configuredMainActivity can receive scheme://app-intents
links without replacing existing app or Expo dev-client deep-link filtersAppDelegate.swiftCodegen handles the generated Swift and Android XML files, but bare iOS apps still need to forward
home-screen quick actions from AppDelegate.swift:
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
// ... existing startup ...
if let shortcutItem = launchOptions?[.shortcutItem] as? UIApplicationShortcutItem,
handleShortcutItem(shortcutItem) {
return false
}
return true
}
func application(
_ application: UIApplication,
performActionFor shortcutItem: UIApplicationShortcutItem,
completionHandler: @escaping (Bool) -> Void
) {
completionHandler(handleShortcutItem(shortcutItem))
}
private func handleShortcutItem(_ shortcutItem: UIApplicationShortcutItem) -> Bool {
guard let url = shortcutItem.userInfo?["url"] as? String else {
return false
}
ReactNativeAppIntents.recordIncomingURLString(url)
return true
}
Android app-intents links are routed through the generated manifest intent filter
for scheme://app-intents. Normal app deep links should keep flowing through
React Native Linking. The native module records app-intents links itself, from
the launch intent and from onNewIntent, so no MainActivity code is needed.
Calling ReactNativeAppIntentsModule.handleIntent from MainActivity is optional
and kept for older setups; an intent is never recorded twice.
import { createAppIntentsRuntime } from "@avasapp/react-native-app-intents";
import { openOrder, openSavedOrder } from "./orders.intents";
const appIntents = createAppIntentsRuntime({
scheme: "myapp",
intents: [openOrder, openSavedOrder] as const,
});
const initialIntent = await appIntents.getInitialIntent();
if (initialIntent?.id === "openOrder") {
// Navigate from a cold launch.
}
const unsubscribe = appIntents.onIntent(openOrder, (params) => {
// Navigate from a warm/background launch.
});
await appIntents.updateDynamicShortcuts([
{
icon: {
androidResourceName: "@mipmap/ic_launcher_round",
iosTemplateImageName: "burger",
systemName: "shippingbox",
},
intent: openOrder,
params: { orderNumber: "1234" },
shortTitle: "Open order #1234",
longTitle: "Taylor",
},
]);
surfaces.appShortcut can be either true or an object with an iOS SF Symbol
(systemName) and/or an Android shortcut resource reference (androidResourceName).
For dynamic shortcuts, icon can additionally include iosTemplateImageName.
await appIntents.donate(openOrder, { orderNumber: "1234" });
await appIntents.clearDonations();
On iOS this creates an NSUserActivity eligible for system predictions and clears donated
interactions/user activities. On Android this publishes a removable long-lived shortcut donation and
clears the shortcut donations created by donate.
For auth-gated or feature-flagged flows, treat donations and dynamic shortcuts as derived session state. Donate when the user completes a real action, and clear everything on logout or when the feature is disabled:
import { useEffect } from "react";
import { createAppIntentsRuntime } from "@avasapp/react-native-app-intents";
import { openOrder } from "./orders.intents";
const appIntents = createAppIntentsRuntime({
scheme: "myapp",
intents: [openOrder] as const,
});
async function handleOpenedOrder(orderNumber: string) {
// Only donate actions the user actually performed.
await appIntents.donate(openOrder, { orderNumber });
}
useEffect(() => {
if (!session || !flags.orderShortcuts) {
void appIntents.clearDonations();
void appIntents.updateDynamicShortcuts([]);
return;
}
void appIntents.updateDynamicShortcuts([
{
intent: openOrder,
params: { orderNumber: session.lastViewedOrderNumber },
shortTitle: "Open last order",
longTitle: `Open order ${session.lastViewedOrderNumber}`,
},
]);
}, [session, flags.orderShortcuts]);
async function logout() {
await auth.signOut();
await appIntents.clearDonations();
await appIntents.updateDynamicShortcuts([]);
}
This keeps Siri/App Shortcuts suggestions aligned with the current account state instead of exposing stale shortcuts after logout.
An entity with catalog: "runtime" takes its values from JavaScript at run time
instead of the values baked in at codegen.
export const order = defineEntity({
id: "order",
title: "Order",
catalog: "runtime",
schema: p.object({ orderNumber: p.string() }),
identifier: (order) => order.orderNumber,
displayRepresentation: (order) => ({ title: `Order ${order.orderNumber}` }),
});
await appIntents.setEntities(order, [
{
id: "4521",
title: "Order 4521",
subtitle: "Arrives Tue",
synonyms: ["last order"],
value: { orderNumber: "4521" },
},
]);
const orders = await appIntents.getEntities(order);
setEntities checks that every entry has a non-empty id and title and a unique
id; a bad entry rejects and leaves the stored catalog unchanged. Publishing a
catalog equal to the current one is a no-op, so calling setEntities on every
launch is safe. Static inventory seeds Siri and Shortcuts, but a Spotlight entity
is not indexed until the first setEntities or reindexEntities.
The catalog is stored natively on the device (UserDefaults on iOS, shared
preferences on Android), so keep it to the rows Siri and agents need. Clear it
on logout with setEntities(order, []).
Index an entity in Spotlight (iOS 18+) so it appears in search and Apple Intelligence. Tapping a result runs its open intent.
export const order = defineEntity({
id: "order",
title: "Order",
catalog: "runtime",
schema: p.object({ orderNumber: p.string() }),
identifier: (order) => order.orderNumber,
displayRepresentation: (order) => ({ title: `Order ${order.orderNumber}` }),
spotlight: { openIntent: "openOrder" },
});
spotlight.openIntent is the id of an intent that takes exactly one required
parameter of this entity. Spotlight requires catalog: "runtime". An entry with
hideInSpotlight: true stays resolvable but is not indexed. Indexing follows the
published catalog: added and changed entries are indexed, removed entries are
deleted. reindexEntities(entity) forces a full rebuild of the index for one entity,
or for every spotlight entity when called with no argument, for example after a
failed sync. A system-evicted index is rebuilt automatically.
Tell Siri and Apple Intelligence which entity the screen is showing (iOS 18.2+), so requests like “send this” or “summarize this” resolve.
useOnscreenEntity(order, selectedOrder?.id);
Pass the entity and the id on screen; pass null or undefined to clear it.
Tag a single view, such as a list row, with the entity it shows (iOS 18.4+).
const ref = useRef<View>(null);
useAppEntityTag(ref, order, row.id);
<View ref={ref} collapsable={false}>
…
</View>;
The view needs collapsable={false} so it exists as a native view. The tag is cleared on unmount or when the id changes. It does nothing on Android and older iOS.
reindexEntities, useOnscreenEntity, useAppEntityTag and Spotlight are
iOS-only. On Android they resolve and do nothing. setEntities and getEntities
work on both platforms.
android.appAction to opt an intent into Android App Actions.surfaces.assistant and top-level androidBii are legacy shims and should be avoided in new intent definitions.| Scenario | Status | Coverage |
|---|---|---|
actions.intent.GET_ORDER scalar slot binding |
Supported | Core validation, codegen snapshot, runtime test |
actions.intent.GET_ORDER entity-backed shortcut inventory |
Supported | Core validation, codegen snapshot, example app |
| Capability-bound Android donations and dynamic shortcuts | Supported | Runtime test, Android native module wiring |
Legacy surfaces.assistant / top-level androidBii usage |
Compatibility only | Core validation |
| Google Assistant voice triggering | Best effort | Manual verification only |
| Verified App Links / Play Console review steps | Manual setup required | Codegen diagnostics |
For an opt-in adb smoke test against the bare Android example app, run:
RN_APP_INTENTS_ANDROID_E2E=1 bun test packages/react-native/test/android-app-actions.e2e.test.ts
Android AppFunctions (Android 16+) let Gemini and other on-device agents call an intent directly. It is opt-in at two levels: android.appFunctions in the codegen config turns generation on for the project, and android.appFunction on an intent exposes that intent. Turning on the project setting on its own exposes nothing.
AppFunctions need React Native 0.88+ (AGP 9.1+), compileSdk 37 and KSP. Add the KSP plugin to android/build.gradle:
buildscript {
dependencies {
classpath("com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:2.2.0-2.0.2")
}
}
Apply it and add the dependencies in android/app/build.gradle, then set the SDK in android/gradle.properties:
apply plugin: "com.google.devtools.ksp"
dependencies {
implementation("androidx.appfunctions:appfunctions:1.0.0")
ksp("androidx.appfunctions:appfunctions-compiler:1.0.0")
}
android.compileSdkVersion=37
The KSP plugin version follows the app’s Kotlin version; 2.2.0-2.0.2 matches Kotlin 2.2.0 on React Native 0.88. The Expo plugin adds the plugin, both dependencies and compileSdk 37 during prebuild when android.appFunctions is set, so none of these lines are needed there.
Enable it in the config:
export default defineAppIntentsConfig({
intents: ["src/**/*.intents.ts"],
scheme: "myapp",
android: {
manifest: "android/app/src/main/AndroidManifest.xml",
shortcutsOutput: "android/app/src/main/res/xml/app_shortcuts.xml",
packageName: "com.example.myapp",
appFunctions: {
output: "android/app/src/main/java/com/example/myapp/appfunctions/AppFunctions.kt",
appMetadata: { instructions: "Order tracking for the shop." },
},
},
});
Then opt an intent in, and optionally an entity query:
export const order = defineEntity({
id: "order",
title: "Order",
catalog: "runtime",
schema: p.object({ orderNumber: p.string() }),
identifier: (order) => order.orderNumber,
displayRepresentation: (order) => ({ title: `Order ${order.orderNumber}` }),
android: { appFunctionQuery: true },
});
export const openOrder = defineIntent({
id: "openOrder",
title: "Open Order",
description: "Open a saved order.",
params: {
order: p.entity(order, { title: "Order", prompt: "Which order?" }),
note: p.string({ optional: true, title: "Note", prompt: "Add a note." }),
},
android: { appFunction: true },
behavior: { opensAppToForeground: true },
});
android.appFunctionQuery generates a find<Entity>s(query: String?) function so the agent can resolve an entity before calling the intent.
Parameters map to Kotlin types:
| Definition | AppFunction type |
|---|---|
p.string() |
String |
p.int() |
Int |
p.number() |
Double |
p.bool() |
Boolean |
p.date() |
String (ISO-8601) |
p.object({ ... }) |
generated @AppFunctionSerializable class |
p.entity(Order) |
generated OrderEntity class |
Optional parameters are nullable. A default is applied in the function body, because agents send null or a zero value for omitted parameters, so Kotlin parameter defaults do not apply. The function KDoc is built from title, description and each parameter’s title/prompt, which the agent reads; only the base locale is emitted.
Calls arrive in onIntent like any other intent, with the same payload and invocation id. The function returns status: "delivered" and the invocation id as soon as the call is queued, and does not wait for JS. If the intent has behavior.opensAppToForeground, the app is opened as a best effort: Android 16 blocks background activity launches, so a blocked call stays queued until the app is opened.
setEntities also works on Android now, storing the catalog on the device. The generated find<Entity>s functions read that catalog and use the codegen inventory when nothing is stored.
Set android.appFunction: { enabledByDefault: false } to gate a function, then enable or disable it at runtime:
await appIntents.setAppFunctionEnabled(openOrder, true);
setAppFunctionEnabled(intent, enabled) is a no-op on iOS, on web and below Android 16.
To check generated functions, use an Android 16 QPR2 or newer image:
adb shell cmd app_function list-app-functions --package com.example.myapp
adb shell cmd app_function execute-app-function --package com.example.myapp ...
Calls from Gemini also require the app to be in Google’s Connected Apps Platform developer preview.
ios.appIntent to opt an intent into native Siri/App Intents generation.surfaces.siri no longer enables App Intents by itself; keep using surfaces.appShortcut and surfaces.spotlight for those separate surfaces.ios.appIntent.response.dialog is supported only for background intents; it cannot be combined with behavior.opensAppToForeground.object params are flattened into Swift leaf parameters for App Intents, but phrases cannot interpolate the object parameter itself.| Scenario | Status | Coverage |
|---|---|---|
ios.appIntent foreground URL handoff |
Supported | Codegen snapshot, runtime tests, example app |
Static ios.appIntent.response.dialog |
Supported | Core validation, Swift typecheck, snapshot |
Nested object params in generated App Intents |
Supported | Core validation, Swift typecheck, snapshot |
surfaces.siri without ios.appIntent |
Unsupported | Core validation |
Object-param placeholders inside phrases |
Unsupported | Core validation |
| Custom bundled image assets in generated App Shortcuts | Unsupported | Documentation only |
| Dynamic Siri dialog sourced from JS/native perform logic | Not yet supported | Explicit non-goal for current slice |
defineIntent, defineEntity, and p.* parameter builders.android.appAction authoring plus Android shortcuts XML, strings XML, and manifest patching.ios.appIntent authoring plus Swift App Intents/App Shortcuts generation.ios.appIntent.response.dialog.This repository includes a GitHub Actions workflow that builds this docs/ directory with GitHub
Pages. In the GitHub repository settings, set Pages -> Build and deployment -> Source to
GitHub Actions. Push to main, then open:
https://avas-app.github.io/react-native-app-intents/