# @vmutafov/firebase-auth-node-browser

> Extension for Firebase Auth allowing signing in in from a browser

Latest version **0.1.0** (published 2023-03-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install @vmutafov/firebase-auth-node-browser
pnpm add @vmutafov/firebase-auth-node-browser
yarn add @vmutafov/firebase-auth-node-browser
bun add @vmutafov/firebase-auth-node-browser
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2023-03-26 |
| First published | 2023-03-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 15.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Vladimir Mutafov |
| Maintainers | vmutafov |
| Keywords | Firebase, Auth, Browser login, NodeJS |

## Links

- npm: https://www.npmjs.com/package/@vmutafov/firebase-auth-node-browser
- Repository: https://github.com/vmutafov/firebase-auth-node-browser
- Homepage: https://github.com/vmutafov/firebase-auth-node-browser#readme
- Issues: https://github.com/vmutafov/firebase-auth-node-browser/issues
- npm.io page: https://npm.io/package/@vmutafov/firebase-auth-node-browser

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2023-03-26

## README

# Firebase Auth NodeJS Browser Login

[![npm version](https://badge.fury.io/js/@vmutafov%2Ffirebase-auth-node-browser.svg)](https://badge.fury.io/js/@vmutafov%2Ffirebase-auth-node-browser)


## What?
This library provides the function `signInWithBrowser` that could be used from NodeJS applications in order to open up a browser and log in from there. 

## Why?
There are use cases where you may want to support Google, Facebook or other third-party authentication and authorization services in your NodeJS app. For example, if you are building a CLI that requires users to log in, it may be easier for users to log in with, for example - Google. Currently, as the Firebase's client SDK does not support federated authentication when running in NodeJS, this functionality is a bit hard to achieve only by using the Firebase SDK.

## How?
In order to use this library, first install it through npm:
```
npm i @vmutafov/firebase-auth-node-browser
```
After that, you only need to call the `signInWithBrowser` function:
```TypeScript
import { getAuth, GoogleAuthProvider } from "firebase/auth";
import { signInWithBrowser } from "@vmutafov/firebase-auth-node-browser";

const auth = getAuth();
const userCredential = await signInWithBrowser(auth, new GoogleAuthProvider());
```

You can either pass a single `AuthProvider` like in the example above or pass multiple ones:
```TypeScript
import { getAuth, GoogleAuthProvider, FacebookAuthProvider, EmailAuthProvider } from "firebase/auth";
import { signInWithBrowser } from "@vmutafov/firebase-auth-node-browser";

const auth = getAuth();
const authProviders = [new GoogleAuthProvider(), new FacebookAuthProvider(), new EmailAuthProvider()]
const userCredential = await signInWithBrowser(auth, authProviders);
```

The difference with this approach is that when `signInWithBrowser` is called, the user would be able to choose between all authentication providers. 
Internally, this library uses [FirebaseUI for Web](https://github.com/firebase/firebaseui-web) and the UI is the default one from it.

## Demo?

There is an example project inside the `demo` folder. In order to start it, run `npm i` and then `npm start`. You should then be navigated to your default browser and you should see the different authentication options.

---
_Source: https://npm.io/package/@vmutafov/firebase-auth-node-browser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
