Releases: Timonwa/firebase-hooks
Release list
@timonwa/firebase-hooks@0.2.0
Minor Changes
-
#20
ca73117Thanks @Timonwa! - Theauthargument is now optional. Below anAuthProvider, hooks take the instance from it, so an app no longer names the same object at every call site:const { login } = useLogin(); const { signup } = useSignup({ sendVerificationEmail: false });
Passing your own still works and overrides the provider's — what you need for a second Firebase project, or with no provider at all.
nullkeeps its existing meaning of "not ready yet, don't run", so a hook held back while Firebase initialises never silently runs against the provider's instance instead.Breaking:
useUpdatePasswordanduseUpdateEmailtake the new value positionally, matching the Firebase SDK they wrap anduseSignup's existing shape.// Before await update({ newPassword, currentPassword }); await update({ newEmail, currentPassword }); // After await update(newPassword, { currentPassword }); await update(newEmail, { currentPassword });
Firebase's own
updatePassword(user, newPassword)andverifyBeforeUpdateEmail(user, newEmail)lead with the required value;currentPasswordis the reauthentication these hooks add on top, so it belongs in the options bag after it.useUpdateProfileis unchanged — its fields are all optional, which is why the SDK passes them as an object too.Nothing else changes: every existing
useLogin(auth, options)call keeps working.
Patch Changes
v0.1.0
Minor Changes
-
#11
fe2779cThanks @Timonwa! - Initial release. Typed React hooks for Firebase, one import per service. This release covers the shared core and the Auth service; Firestore and Storage follow.Auth —
@timonwa/firebase-hooks/authAuthProvider/useAuth— live user and custom claims viaonIdTokenChanged, plus app-wide defaults.- Sign in —
useLogin,useSignup,useOAuthSignIn(popup or redirect, redirect completed on return),useEmailLinkSignIn(needsEmailinstead ofwindow.prompt),usePhoneSignIn(managed reCAPTCHA,recaptchaSizeoption),useAnonymousSignIn,useCustomTokenSignIn,useLogout(your session teardown runs first). - Passwords —
useSendPasswordResetEmail,useConfirmPasswordReset(withverifyCode),useUpdatePassword. - Email —
useVerifyEmail,useSendEmailVerification,useUpdateEmail. - Account —
useUpdateProfile,useDeleteAccount,useReauthenticate,useLinkProvider,useUnlinkProvider. AUTH_ERROR_MESSAGES— a curatedauth/*message catalogue, applied only if you opt in.
Core —
@timonwa/firebase-hooksformatFirebaseError,getFirebaseErrorCode, and the sharedHookResult,HookErrorOptions,HookErrorContext,FormatFirebaseErrorOptions, andOnIdTokentypes.How it behaves
- Actions never throw. Each resolves to
{ success: true, ... }or{ success: false, error, code, cause }, whereerroris Firebase's own message unless you opt into formatting, andcauseis the untouched error. - Sign-in successes hand back Firebase's raw
UserCredentialalongside the user. - Server sessions plug in through
onIdTokenandonBeforeSignOut; throw inside either to abort the flow. onIdToken,onBeforeSignOut,actionCodeSettings,formatErrorMessage, and a fire-and-forgetonError(error, { action, code, message })observer are set once onAuthProvider; any hook can override them or opt out withnull.- Sensitive operations reauthenticate when given
currentPassword, and work without it for OAuth-only accounts.
Zero dependencies —
firebaseandreactare peers. Ships ESM and CJS with type declarations and a"use client"banner.
@timonwa/firebase-hooks@0.1.1
Patch Changes
-
#13
c905822Thanks @Timonwa! - Document every hook option in the published types. EachUse<Name>OptionsPropsfield now carries TSDoc, with its default where it has one, so editors show what an option does at the call site instead of only its type.Also exposes
./package.jsonas a subpath export, so tooling can read the version without reaching into the package directory.No runtime change — every hook behaves exactly as before.