# Cannot read properties of undefined (reading 'Auth0Client')

**URL:** <https://community.auth0.com/t/cannot-read-properties-of-undefined-reading-auth0client/116449>\
**Category:** Get Help\
**Tags:** configuration, application\
**Created:** [September 18, 2023, 2:52am UTC](https://community.auth0.com/t/cannot-read-properties-of-undefined-reading-auth0client/116449 "2023-09-18T02:52:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael26](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@michael26](https://community.auth0.com/u/michael26)\
**Post date:** [September 18, 2023, 2:52am UTC](https://community.auth0.com/t/cannot-read-properties-of-undefined-reading-auth0client/116449/1 "2023-09-18T02:52:20Z")

</div>

When calling the following, I get the error “Cannot read properties of undefined (reading ‘Auth0Client’)”. What causes this?

```
  auth0Web.onLoad().then((final credentials) => setState(() {
    _user = credentials?.user;
  }));

```

---

<div class="post-metadata">

**Author:** ![pratyush.pandey](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pratyush.pandey/32/53671_2.png) [@pratyush.pandey](https://community.auth0.com/u/pratyush.pandey)\
**Post date:** [January 24, 2024, 7:25pm UTC](https://community.auth0.com/t/cannot-read-properties-of-undefined-reading-auth0client/116449/2 "2024-01-24T19:25:11Z")

</div>

The error message “Cannot read properties of undefined (reading ‘Auth0Client’)” typically occurs when you’re trying to access a property or method of an object that hasn’t been initialized yet. In this case, it seems like `auth0Web` might be `undefined` when you’re trying to call `onLoad()` on it.

Here are a few things you could check:

Ensure that `auth0Web` is properly initialized before this code runs. It should be an instance of `Auth0Client` .

Check if the Auth0 library is correctly imported and available in the scope where you’re trying to use it.

If the Auth0 library is being loaded asynchronously, there might be a timing issue where your code is running before the library has fully loaded. You might need to add some checks or use a callback to ensure the library is loaded before running your code.

There might be an issue with the configuration of the Auth0 client. Make sure all the necessary parameters (like domain and client ID) are correctly set.

> [@TypeError: Cannot read property 'close' of undefined when using new auth0-spa library in Angular interceptor](https://community.auth0.com/t/typeerror-cannot-read-property-close-of-undefined-when-using-new-auth0-spa-library-in-angular-interceptor/28010):
>
> Hi everyone, I am currently working on replacing the old auth0-js implementation of our application with your new auth0-spa-js library. Even though I got it to work somehow, I am always getting the following error on the console which is caught by my error handler: TypeError: Cannot read property 'close' of undefined at a (auth0-spa-js.production.js:1) at ZoneDelegate.push../node\_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423) at Object.onInvokeTask (core.js:1729…

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [May 31, 2024, 4:08pm UTC](https://community.auth0.com/t/cannot-read-properties-of-undefined-reading-auth0client/116449/3 "2024-05-31T16:08:44Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
