auth0-angular
auth0-angular copied to clipboard
APP_INITIALIZER is deprecated
Checklist
- [x] The issue can be reproduced in the auth0-angular sample app (or N/A).
- [x] I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- [x] I have looked into the API documentation and have not found a suitable solution or answer.
- [x] I have searched the issues and have not found a suitable solution or answer.
- [x] I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- [x] I agree to the terms within the Auth0 Code of Conduct.
Description
As seen per documenation:
providers: [
{
provide: APP_INITIALIZER,
useFactory: configInitializer, // <- pass your initializer function here
deps: [HttpBackend, AuthClientConfig],
multi: true,
},
],
This is no longer valid.
Also, instead of AuthModule.forRoot it would be nice if we could use something like withAuth0(...)
Reproduction
Just use the way of the documentation
Additional context
No response
auth0-angular version
2.2.3
Angular version
21
Which browsers have you tested in?
Chrome
We have aprovideAuth0, see https://github.com/auth0/auth0-angular/blob/main/EXAMPLES.md#standalone-components-and-a-more-functional-approach.
We can update docs to use the recommended way with Angular 19 and above, which would be:
provideAppInitializer(() => configInitializer(inject(HttpBackend), inject(AuthClientConfig)))
Additionally, we should consider to update the README to use all of this by default.