Skip to content

AsgardeoProvider throws undefined property error if preferences not passed #192

@anjanarodrigoz

Description

@anjanarodrigoz

Description

Issue

When using with only clientId and baseUrl, the app crashes with the following error:
Uncaught TypeError: Cannot read properties of undefined (reading 'theme') at AsgardeoProvider (@asgardeo_react.js:21096:52)

Code That Causes the Error

<AsgardeoProvider
  clientId={import.meta.env.VITE_CLIENT_ID}
  baseUrl={import.meta.env.VITE_BASE_URL}
>
  <App />
</AsgardeoProvider>

Workaround

The error goes away if I explicitly pass a preferences object with theme, even if it’s empty:

<AsgardeoProvider
  clientId={import.meta.env.VITE_CLIENT_ID}
  baseUrl={import.meta.env.VITE_BASE_URL}
  preferences={{
    theme: {},
  }}
>
  <App />
</AsgardeoProvider>

Steps to Reproduce

  1. Create a React + Vite project.
  2. Install and import @asgardeo/react.
  3. Wrap your app in with only clientId and baseUrl.
  4. Run the app → it crashes with Cannot read properties of undefined (reading 'theme').

Please select the area the issue is related to

@asgardeo/react

Version

0.5.25

Environment Details (with versions)

Package: @asgardeo/react
Environment:
• React + Vite
node version : v23.11.0
• Local dev (localhost:3000)
• Using @asgardeo/react latest version

Reporter Checklist

  • I have searched the existing issues and this is not a duplicate.
  • I have provided all the necessary information.
  • I have tested the issue on the latest version of the package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions