{"id":13680872,"url":"https://github.com/benweier/connect-session-firebase","last_synced_at":"2025-10-29T05:16:25.978Z","repository":{"id":43820380,"uuid":"61430368","full_name":"benweier/connect-session-firebase","owner":"benweier","description":"A Connect/Express session store powered by the Firebase Realtime Database.","archived":false,"fork":false,"pushed_at":"2023-06-01T19:56:42.000Z","size":2135,"stargazers_count":41,"open_issues_count":7,"forks_count":13,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-27T23:41:47.770Z","etag":null,"topics":["connect","cookie","database","express","firebase","node","session"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benweier.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"benweier","ko_fi":"benweier"}},"created_at":"2016-06-18T11:27:01.000Z","updated_at":"2025-03-03T01:57:01.000Z","dependencies_parsed_at":"2024-01-14T15:20:58.152Z","dependency_job_id":null,"html_url":"https://github.com/benweier/connect-session-firebase","commit_stats":{"total_commits":400,"total_committers":10,"mean_commits":40.0,"dds":"0.26749999999999996","last_synced_commit":"875e2b237e4ce30d6df91012819c550193d4f890"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benweier%2Fconnect-session-firebase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benweier%2Fconnect-session-firebase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benweier%2Fconnect-session-firebase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benweier%2Fconnect-session-firebase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benweier","download_url":"https://codeload.github.com/benweier/connect-session-firebase/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248862534,"owners_count":21173829,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["connect","cookie","database","express","firebase","node","session"],"created_at":"2024-08-02T13:01:23.252Z","updated_at":"2025-10-29T05:16:20.930Z","avatar_url":"https://github.com/benweier.png","language":"JavaScript","funding_links":["https://github.com/sponsors/benweier","https://ko-fi.com/benweier"],"categories":["JavaScript"],"sub_categories":[],"readme":"# Connect Session Firebase\n\n[![build](https://github.com/benweier/connect-session-firebase/actions/workflows/main.yml/badge.svg)](https://github.com/benweier/connect-session-firebase/actions/workflows/main.yml)\n[![codecov](https://codecov.io/gh/benweier/connect-session-firebase/branch/master/graph/badge.svg?token=B5d97oXnOM)](https://codecov.io/gh/benweier/connect-session-firebase)\n\n`connect-session-firebase` is a Connect/Express compatible session store backed by the [Firebase SDK](https://firebase.google.com/docs/admin/setup).\n\n## Installation\n\n`firebase-admin` must be added as a peer dependency, or you're gonna have a bad time. `connect-session-firebase` expects a only matching `major` version of Firebase, i.e. any `connect-session-firebase@11.x.x` version will expect any `firebase-admin@11.x.x` version peer dependency.\n\n    $ npm install firebase-admin connect-session-firebase --save\n\n## Options\n\n- `database` A pre-initialized Firebase Database app instance.\n- `sessions` (optional) A child reference string for session storage. (defaults to \"sessions\")\n- `reapInterval` (optional) How often expired sessions should be cleaned up. (defaults to `21600000`, 6 hours in milliseconds)\n- `reapCallback` (optional) A callback function to execute whenever a session clean up occurs.\n- `errorIfSessionNotFound` (optional) Return an error object to the callback if a session doesn't exist. Only useful if you want to log when a session is no longer available. (defaults to `false`)\n\n## Usage\n\nInitialize `firebase-admin` database and pass the instance to `FirebaseStore`. Connecting to the database requires a credential cert via a JSON file from the [Firebase IAM \u0026 Admin Console](https://console.firebase.google.com/iam-admin/projects).\n\n- [Connect](http://senchalabs.github.io/connect)\n\n```js\nconst connect = require('connect')\nconst FirebaseStore = require('connect-session-firebase')(connect)\nconst firebase = require('firebase-admin')\nconst ref = firebase.initializeApp({\n  credential: firebase.credential.cert('path/to/serviceAccountCredentials.json'),\n  databaseURL: 'https://databaseName.firebaseio.com',\n})\n\nconnect()\n  .use(connect.cookieParser())\n  .use(\n    connect.session({\n      store: new FirebaseStore({\n        database: ref.database(),\n      }),\n      secret: 'keyboard cat',\n    }),\n  )\n```\n\n- [Express](http://expressjs.com)\n\n  **NOTE:** In Express 4 `express-session` must be passed to the function `connect-session-firebase` exports in order to extend `express-session.Store`:\n\n```js\nconst express = require('express');\nconst session = require('express-session');\nconst FirebaseStore = require('connect-session-firebase')(session);\nconst firebase = require('firebase-admin');\nconst ref = firebase.initializeApp({\n  credential: firebase.credential.cert('path/to/serviceAccountCredentials.json'),\n  databaseURL: 'https://databaseName.firebaseio.com'\n});\n\nexpress()\n  .use(session({\n    store: new FirebaseStore({\n      database: ref.database()\n    }),\n    secret: 'keyboard cat'\n    resave: true,\n    saveUninitialized: true\n  }));\n```\n\n## Security\n\nIf you use a publicly available Firebase Database, please set proper rules:\n\n```json\n{\n  \"rules\": {\n    \".read\": \"false\",\n    \".write\": \"false\",\n    \"sessions\": {\n      \".read\": \"false\",\n      \".write\": \"false\"\n    },\n    \"some_public_data\": {\n      \".read\": \"true\",\n      \".write\": \"auth !== null\"\n    }\n  }\n}\n```\n\nLearn more about Firebase rules: https://firebase.google.com/docs/database/security/\n\n## Tests\n\nTo run tests against `connect-session-firebase` you will need your own Firebase Database app available.\n\nCheckout the repo locally and create two files in the project root:\n\n- .env\n- serviceAccountCredentials.json\n\nWith the content:\n\n**.env**\n\n```\nFIREBASE_SERVICE_ACCOUNT=./serviceAccountCredentials.json\nFIREBASE_DATABASE_URL=https://[databaseName].firebaseio.com\n```\n\n**serviceAccountCredentials.json**\n\n```\n{\n  \"type\": \"service_account\",\n  \"project_id\": \"\",\n  \"private_key_id\": \"\",\n  \"private_key\": \"\",\n  \"client_email\": \"\",\n  \"client_id\": \"\",\n  \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n  \"token_uri\": \"https://accounts.google.com/o/oauth2/token\",\n  \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n  \"client_x509_cert_url\": \"\"\n}\n```\n\nInstall the dev dependencies:\n\n    $ npm install\n\nRun the tests:\n\n    $ npm test\n\n## License\n\n`connect-session-firebase` is licensed under the [MIT license](https://github.com/benweier/connect-session-firebase/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenweier%2Fconnect-session-firebase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenweier%2Fconnect-session-firebase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenweier%2Fconnect-session-firebase/lists"}