Search code examples
angularfirebaseangularfire

What is the correct way of importing AngularFireAuth?


I tried this as mentioned in the official doc, like the following, which works fine.

import { AngularFireAuth } from '@angular/fire/auth

But the VSC tools autosuggest like the following which also works fine.

import { AngularFireAuth } from '@angular/fire/auth/auth

Are the above mentioned versions equivalent? If not, what are the differences? What is the best way of importing AngularFireAuth?


Solution

  • According to the source code:

    • importing from @angular/fire/auth would import from this file which in TypeScript also called barrel.

    • importing from @angular/fire/auth/auth would import from this file

    Conclusion - the two imports are equivalent since the barrel re-exports the same file.

    Regarding the "best way", I always prefer to import from package's public API, since these exports are what actually meant to be consumed by users.