TypeError: Cannot read property 'createConfig' of null during Okta initialization in React Native Typescript Android app

Hello Okta Support,

I’m encountering a runtime error while integrating Okta into my React Native (Typescript) Android application. The error occurs during the initialization phase and prevents the app from proceeding with authentication.

Error Message:

Code

TypeError: Cannot read property 'createConfig' of null
    at createConfigWithCallbacks (index.bundle:194216:60)
    at createConfig (index.bundle:194246:25)
    at initOkta (index.bundle:193874:28)
    ...

Environment Details:

  • Platform: Android

  • Framework: React Native - Typescript

  • package used: @okta/okta-react-native

Steps Taken:

  • Followed Okta React Native SDK setup instructions

  • Verified native module linking

  • Confirmed that createConfig is being called with valid parameters

Suspected Cause: It appears that the native module may not be properly initialized or is returning null, causing createConfig to fail. This might be related to auto-linking or incorrect setup in MainApplication.java.

Request: Could you please help identify the root cause or suggest steps to resolve this issue? Any guidance on debugging native module initialization for Okta in React Native would be appreciated.

Note : we also tried react-native-app-auth package, it is also giving authorize is undefined.

Thank you!

Hi Dipak! initOkta isn’t something that exists in the okta-react-native library, so the starting point of your stack trace has to be in your code somewhere which would imply something is missing :slight_smile:

If you look at the README in the module source (or at npmjs.com), it suggests import createConfig directly from the module and using it. So any problems with the package and the import would fail at that point.

The other option is to import the module object and then reference createConfig as a property of that, in which case you could be mistaken on the object reference and if it was null when you call the function you’ll get the error described. This is an example of what that technique would look like:

import { OktaAuth } from ‘@okta/okta-react-native’;
import { oktaConfig } from ‘./config’;

OktaAuth.createConfig(oktaConfig);

I would really have to see your code in order to tell you where it is going wrong. Hopefully this explanation may trigger something for you.

1 Like

Hi @jmussman

Correct — initOkta is just a function we wrote in our code; it is not from Okta. Could we have a quick working session on this? Please let me know your availability so I can schedule it.

Thanks and best regards,