# @vmutafov/firebase-auth-node-persistence

> Configurable file-based Firebase Authentication NodeJS persistence

Latest version **0.1.1** (published 2023-03-25) · ISC license · 0 weekly downloads

## Install

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

## 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.1 |
| Published | 2023-03-25 |
| First published | 2023-03-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Vladimir Mutafov |
| Maintainers | vmutafov |
| Keywords | Firebase, Auth, File persistence, NodeJS |

## Links

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

## 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.1 (latest) — 2023-03-25
- 0.1.0 — 2023-03-24

## README

# Firebase  Auth NodeJS Persistence

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


## What?
This library is a simple file-based [Firebase Auth](https://firebase.google.com/docs/auth) NodeJS persistence provider. The idea behind it is that at the time of writing, [Firebase's client SDK](https://www.npmjs.com/package/firebase) does not have persistent authentication storage when running in NodeJS - it only has an in-memory one. This is quite different from its usage in the browser where the Local Storage, Session Storage, or IndexedDB could be used.

## Why?
There are use cases where having persistent authentication may be necessary for NodeJS applications:
- having a CLI application where you want users to log in via dedicated command and not to be prompted on every next command to log in, e.g. the Firebase CLI where you log in once and you are not required to log in on each command
- transferring your authenticated user to another machine or another NodeJS process

## How?
Using the library is rather simple, you only need to initialize the Firebase Auth explicitly setting the persistence:
```TypeScript
import { getApp } from "firebase/app";
import { initializeAuth } from "firebase/auth";
import { createNodeFilePersistence } from "@vmutafov/firebase-auth-node-persistence";
import { resolve } from "node:path";
import { cwd } from "node:process";

const app = getApp();

const nodeFilePersistence = createNodeFilePersistence({
    filePath: resolve(cwd(), '.appwrapsrc')
});

const auth = initializeAuth(app, {
    persistence: [nodeFilePersistence]
});
```

Setting the `filePath` property of the configuration options for the `createNodeFilePersistence` function allows you to specify a file that would be used for storing the authentication data.

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