Giter Club home page Giter Club logo

next-firebase-authentication's Introduction

Overview

next-firebase-authentication makes it easy to connect Next.js to Firebase Authentication.

Example

Getting Started

1. Install

npm i -S next-firebase-authentication
yarn add next-firebase-authentication

2. Set environment variables

NEXT_PUBLIC_FIREBASE_API_KEY="..."
NEXT_PUBLIC_FIREBASE_APP_ID="..."
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN="..."
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID="..."
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID="..."
NEXT_PUBLIC_FIREBASE_PROJECT_ID="..."
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET="..."

If you want to verify id token, add the following environment variables.

FIREBASE_CLIENT_EMAIL="..."
FIREBASE_PRIVATE_KEY="..."
FIREBASE_PROJECT_ID="..."

3. Initialize Firebase Authentication with App component

_app.tsx

import { useInitAuth } from "next-firebase-authentication";
import type { AppProps } from "next/app";

function MyApp({ Component, pageProps }: AppProps): JSX.Element {
  useInitAuth();

  return <Component {...pageProps} />;
}

export default MyApp;

Reference

useInitAuth

Initialize Firebase Authentication.

Make sure to call it only once with App component.

  • isSignedIn: boolean
  • userCredential?: object

useSignIn

It's hooks about signing in.

  • signInWithFacebook: function
  • signInWithGoogle: function
  • signInWithTwitter: function

useSignOut

It's hooks about signing out.

  • isSignedOut: boolean
  • signOut: function

useUser

It's hooks about user.

  • error: Error
  • isLoading: boolean
  • user: object

verifyIdToken

It is a function that does verify for id token.

Can be used with getServerSideProps and api.

It is also possible to use indirectly from middleware.

Please write as follows when using.

import { verifyIdToken } from "next-firebase-authentication/dist/verifyIdToken";

License

MIT

next-firebase-authentication's People

Contributors

renovate[bot] avatar piro0919 avatar

Stargazers

 avatar Sergey Kurilov avatar

Forkers

lgtm-migrator

next-firebase-authentication's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Warning

These dependencies are deprecated:

Datasource Name Replacement PR?
npm npm-run-all Available

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): replace dependency npm-run-all with npm-run-all2 5.0.0
  • chore(deps): update devdependencies (@types/node, @types/react, @types/react-dom, eslint, eslint-plugin-sort-destructure-keys, eslint-plugin-sort-keys-shorthand, react, react-dom)
  • fix(deps): update dependencies (axios, usehooks-ts)
  • chore(deps): update dependency eslint to v9
  • chore(deps): update dependency eslint-plugin-sort-destructure-keys to v2
  • chore(deps): update dependency eslint-plugin-unused-imports to v4
  • chore(deps): update dependency husky to v9
  • chore(deps): update dependency lint-staged to v15
  • chore(deps): update dependency stylelint to v16
  • chore(deps): update dependency stylelint-config-recommended-scss to v14
  • chore(deps): update dependency stylelint-config-sass-guidelines to v12
  • chore(deps): update dependency stylelint-config-standard to v36
  • chore(deps): update dependency stylelint-config-standard-scss to v13
  • chore(deps): update dependency stylelint-scss to v6
  • fix(deps): update dependency firebase to v10
  • fix(deps): update dependency firebase-admin to v12
  • fix(deps): update dependency usehooks-ts to v3
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • axios 0.27.2
  • firebase 9.23.0
  • firebase-admin 11.11.1
  • nookies 2.5.2
  • react-firebase-hooks 5.1.1
  • usehooks-ts 2.9.1
  • @commitlint/cli 17.8.1
  • @commitlint/config-conventional 17.8.1
  • @types/node 18.19.4
  • @types/react 18.2.46
  • @types/react-dom 18.2.18
  • @typescript-eslint/eslint-plugin 5.62.0
  • @vespaiach/axios-fetch-adapter 0.3.1
  • eslint 8.56.0
  • eslint-config-google 0.14.0
  • eslint-config-next 12.3.4
  • eslint-config-prettier 8.10.0
  • eslint-import-resolver-node 0.3.9
  • eslint-plugin-css-modules 2.12.0
  • eslint-plugin-ext 0.1.0
  • eslint-plugin-filenames 1.3.2
  • eslint-plugin-sort-destructure-keys 1.5.0
  • eslint-plugin-sort-keys-shorthand 2.2.0
  • eslint-plugin-typescript-sort-keys 2.3.0
  • eslint-plugin-unused-imports 2.0.0
  • husky 8.0.3
  • lint-staged 13.3.0
  • next 12.3.4
  • npm-run-all 4.1.5
  • prettier 2.8.8
  • react 18.2.0
  • react-dom 18.2.0
  • stylelint 14.16.1
  • stylelint-config-css-modules 4.4.0
  • stylelint-config-prettier 9.0.5
  • stylelint-config-recommended-scss 7.0.0
  • stylelint-config-sass-guidelines 9.0.1
  • stylelint-config-standard 26.0.0
  • stylelint-config-standard-scss 5.0.0
  • stylelint-order 5.0.0
  • stylelint-scss 4.7.0
  • typescript 4.9.5

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.