{"id":25121308,"url":"https://github.com/flaviodelgrosso/fastify-better-auth","last_synced_at":"2025-04-02T15:22:34.793Z","repository":{"id":276009136,"uuid":"927913704","full_name":"flaviodelgrosso/fastify-better-auth","owner":"flaviodelgrosso","description":"Fastify plugin to simplify the integration of the Better Auth library","archived":false,"fork":false,"pushed_at":"2025-03-31T03:10:46.000Z","size":526,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T04:22:32.641Z","etag":null,"topics":["authentication","better-auth","fastify","fastify-plugin","nodejs"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/fastify-better-auth","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flaviodelgrosso.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-05T18:46:07.000Z","updated_at":"2025-03-31T03:10:42.000Z","dependencies_parsed_at":"2025-02-05T19:57:30.952Z","dependency_job_id":"4056b42f-b769-48b0-80b0-e8fd89363e05","html_url":"https://github.com/flaviodelgrosso/fastify-better-auth","commit_stats":null,"previous_names":["flaviodelgrosso/fastify-better-auth"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaviodelgrosso%2Ffastify-better-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaviodelgrosso%2Ffastify-better-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaviodelgrosso%2Ffastify-better-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaviodelgrosso%2Ffastify-better-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flaviodelgrosso","download_url":"https://codeload.github.com/flaviodelgrosso/fastify-better-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246838039,"owners_count":20841991,"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":["authentication","better-auth","fastify","fastify-plugin","nodejs"],"created_at":"2025-02-08T06:17:43.920Z","updated_at":"2025-04-02T15:22:34.785Z","avatar_url":"https://github.com/flaviodelgrosso.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fastify Better Auth\n\n[![NPM\nversion](https://img.shields.io/npm/v/fastify-better-auth.svg?style=flat)](https://www.npmjs.com/package/fastify-better-auth)\n[![NPM\ndownloads](https://img.shields.io/npm/dm/fastify-better-auth.svg?style=flat)](https://www.npmjs.com/package/fastify-better-auth)\n[![CI](https://github.com/flaviodelgrosso/fastify-better-auth/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/flaviodelgrosso/fastify-better-auth/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/flaviodelgrosso/fastify-better-auth/graph/badge.svg?token=XF947FKO29)](https://codecov.io/gh/flaviodelgrosso/fastify-better-auth)\n\nFastify Better Auth is a Fastify plugin that simplifies the integration of the [Better Auth](https://www.better-auth.com) library into your Fastify applications. This plugin allows you to easily register authentication routes using Better Auth, providing a seamless authentication experience.\n\n## Install\n\n```bash\nnpm install fastify-better-auth\n```\n\n### Usage\n\n```javascript\nimport { betterAuth } from 'better-auth';\nimport { drizzleAdapter } from 'better-auth/adapters/drizzle';\nimport FastifyBetterAuth from 'fastify-better-auth';\nimport fp from 'fastify-plugin';\n\nexport const auth = betterAuth({\n  trustedOrigins: [env.auth.URL],\n  database: drizzleAdapter(db, {\n    provider: 'pg',\n    usePlural: true,\n  }),\n  emailAndPassword: {\n    enabled: true,\n  },\n});\n\nasync function authPlugin(fastify) {\n  await fastify.register(FastifyBetterAuth, { auth });\n}\n\nexport default fp(authPlugin, {\n  name: 'auth-plugin',\n});\n```\n\nYou can now access the auth instance from the Fastify instance. For example if you want get the current session you can do:\n\n```javascript\nconst session = await fastify.auth.api.getSession({\n  headers: fromNodeHeaders(req.headers),\n});\n```\n\n## License\n\nThis project is licensed under the ISC License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflaviodelgrosso%2Ffastify-better-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflaviodelgrosso%2Ffastify-better-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflaviodelgrosso%2Ffastify-better-auth/lists"}