Description
Before opening, please confirm:
- I have searched for duplicate or closed issues and discussions.
- I have read the guide for submitting bug reports.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
JavaScript Framework
React Native
Amplify APIs
GraphQL API
Amplify Version
v6
Amplify Categories
api
Backend
None
Environment information
# Put output below this line
Describe the bug
Hi team,
I am encountering an issue when trying to use GraphQL subscriptions in a React Native project with the @aws-amplify/api package (version 6.x).
Problem details:
• Query and mutation operations work correctly using the generateClient method.
• However, when attempting to subscribe to a GraphQL subscription, I get the following runtime error:
error subscribe [Error: Native module not found] [Component Stack]
• This error appears to be related to missing native WebSocket modules required for subscription support.
• I am using Expo bare workflow, and have confirmed that the environment supports native modules.
• The subscription setup follows the Amplify docs but still fails.
Questions:
1. Is subscription currently fully supported with generateClient in React Native / Expo?
2. If yes, what is the recommended setup or workaround to fix the “Native module not found” error?
3. Are there plans to fix or provide better React Native subscription support in @aws-amplify/api v6?
I would appreciate any guidance or fixes to properly enable subscriptions with Amplify in React Native.
Thank you!
Expected behavior
Subscriptions should connect and receive real-time updates as intended.
Reproduction steps
- Create a React Native project using Expo bare workflow.
- Install @aws-amplify/api version 6 and related Amplify dependencies.
- Configure Amplify with a valid AppSync GraphQL API using generateClient with authMode: "apiKey".
- Implement query and mutation calls using the generated client — these should work fine.
- Implement a GraphQL subscription using the same client’s .graphql({ query }).subscribe() method.
- Run the app on a physical device or emulator.
- Observe the runtime error: Error: Native module not found when starting the subscription.
Code Snippet
// Put your code below this line.
const useGraphQLSubscription = <
TSubscriptionVariables = any,
TSubscriptionResponse = any,
>({
query,
variables,
callback,
enabled = true,
}: Props<TSubscriptionVariables, TSubscriptionResponse>) => {
useEffect(() => {
if (!enabled) return;
const subscription = graphQLClient
.graphql({
query,
variables: variables || ({} as any),
})
.subscribe({
next: ({ data }) => {
callback(data as TSubscriptionResponse);
},
error: (error) => console.warn("error subscribe", error),
});
return () => {
subscription.unsubscribe();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [callback, variables, enabled]);
};
Log output
// Put your logs below this line
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response