stripe-react-native: Expo managed workflow - crash on web
Describe the bug Importing dependencies from @stripe/stripe-react-native causes app to crash on Expo managed workflow - web.
To Reproduce Steps to reproduce the behavior:
- Create new expo managed workflow project
expo install @stripe/stripe-react-native
- import stripe dependencies into component
- expo start --web
- See errors
Expected behavior No errors unless stripe components are actually used at runtime.
Additional context I’m aware that web isn’t supported, but it would be nice if it would at least build so I could run my app. I don’t plan to render any stripe components in the browser at runtime. Currently I can’t figure out a way to make Webpack exclude this dependency. Any help would be greatly appreciated.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 1
- Comments: 22
Let me make the steps explicit for the lazy folks like future me. (All credits to @robert-nash , in his previous answer.)
Add
null-loader
Generate the
webpack.config.js
file with expo’s template:Modify
webpack.config.js
, add the line marked with the commentADD THIS LINE
. Final version of the file should look like:I am still working through the first web build of my app but I seem to have got round this particular error for the meantime by adding null-loader as an alias for @stripe/stripe-react-native in my webpack config.
I added a webpack.config.js as described here and then modified it so it looks like this excerpt. I also installed the null-loader package.
webpack.config.js
hey guyzz for the stripe issue you can initially add null loader like this to resolve the TextInputState Error here is my webpackConfig.js file for adding alias
and create a separate NullModuleloader file like this

@anabeatrizzz
Facing this issue too, the fix posted by @robert-nash / @MehmetKaplan is not working for me.
@olaurendeau I have a workaround for now. I’ve implemented separate application entry points for mobile and web, with a basic dependency injection container to abstract away the platform dependent components. It’s not ideal, but it works.
No. All the errors were introduced when I added the Stripe library.