global.Buffer = require('buffer').Buffer;
import { install } from 'react-native-quick-crypto'
install()
// Needed so that 'stream-http' chooses the right default protocol.
global.location = {
protocol: 'file:',
};
global.process.version = 'v16.0.0';
if (!global.process.version) {
global.process = require('process');
console.log({ process: global.process });
}
process.browser = true;
metro.config.js
const config = {
resolver: {
extraNodeModules: {
assert: require.resolve("empty-module"), // assert can be polyfilled here if needed
http: require.resolve("empty-module"), // stream-http can be polyfilled here if needed
https: require.resolve("empty-module"), // https-browserify can be polyfilled here if needed
os: require.resolve("empty-module"), // os-browserify can be polyfilled here if needed
url: require.resolve("empty-module"), // url can be polyfilled here if needed
zlib: require.resolve("empty-module"), // browserify-zlib can be polyfilled here if needed
path: require.resolve("empty-module"),
crypto: require.resolve("crypto-browserify"),
stream: require.resolve("readable-stream"),
},
sourceExts: [...defaultConfig.resolver.sourceExts, "svg"],
},
};
React Native Version: 0.80.2 (upgraded from 0.74.5, where it was working)
React Version: 19.1.0
Platform: React Native (Bare Workflow)
Error Encountered
TypeError: global.base64FromArrayBuffer is not a function (it is undefined)
This error occurs during login after upgrading React Native.
Provided Configuration
globals.js: Polyfills for Buffer, crypto, process, etc. (using react-native-quick-crypto)
metro.config.js: Custom extraNodeModules for polyfills.
Next Steps & Suggestions
This error suggests that the global function base64FromArrayBuffer is missing after your upgrade. This function is typically polyfilled or provided by certain dependencies, but may be missing or removed in newer React Native versions.
1. Polyfill base64FromArrayBuffer
You may need to manually polyfill this function in your globals.js. Add the following at the top of your globals.js:
Ensure that your entry point (e.g., index.js or App.js) imports globals.js before any other modules that might require these polyfills.
3. Reference Migration Guide
You appear to have followed the migration guide, but double-check the PnP React Native v7 to v8 Migration Guide for any missed steps, especially around globals and polyfills.
If the above does not resolve your issue, please provide:
The Web3Auth initialization and login code snippets.
A screenshot of the browser/dev console or React Native error log.
Any additional custom authentication setup details, if applicable.
Let us know if adding the polyfill resolves the error, or if you need further assistance!
Note: This response was generated by an AI bot and may require further verification. The Web3Auth support team has tracked this issue and will be responding as soon as possible.
Additionally, we would recommend you to join our biweekly Office Hours to get this resolved even faster. Web3Auth Developer Office Hours