{"id":21096844,"url":"https://github.com/stytchauth/stytch-node","last_synced_at":"2026-01-24T01:03:21.666Z","repository":{"id":39674130,"uuid":"309891901","full_name":"stytchauth/stytch-node","owner":"stytchauth","description":"Official Stytch Backend SDK for Node.js","archived":false,"fork":false,"pushed_at":"2025-03-31T20:23:32.000Z","size":2628,"stargazers_count":101,"open_issues_count":6,"forks_count":24,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-01T07:51:38.277Z","etag":null,"topics":["javascript","nodejs","stytch","typescript"],"latest_commit_sha":null,"homepage":"https://stytch.com","language":"TypeScript","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/stytchauth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-04T04:58:27.000Z","updated_at":"2025-03-31T20:23:15.000Z","dependencies_parsed_at":"2023-10-17T02:12:54.876Z","dependency_job_id":"a87ea1a6-7e24-4927-bb8f-ed3e9236b778","html_url":"https://github.com/stytchauth/stytch-node","commit_stats":{"total_commits":178,"total_committers":26,"mean_commits":6.846153846153846,"dds":0.8426966292134832,"last_synced_commit":"867bc96c1dc7e2fc3e0cb4a61fccf064911099bf"},"previous_names":[],"tags_count":172,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stytchauth%2Fstytch-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stytchauth%2Fstytch-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stytchauth%2Fstytch-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stytchauth%2Fstytch-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stytchauth","download_url":"https://codeload.github.com/stytchauth/stytch-node/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247809963,"owners_count":20999816,"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":["javascript","nodejs","stytch","typescript"],"created_at":"2024-11-19T22:44:24.910Z","updated_at":"2026-01-24T01:03:16.647Z","avatar_url":"https://github.com/stytchauth.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stytch Node.js Library\n\nThe Stytch Node library makes it easy to use the Stytch user infrastructure API in server-side JavaScript applications.\n\nIt pairs well with the Stytch [Web SDK](https://www.npmjs.com/package/@stytch/vanilla-js) or your own custom authentication flow.\n\nThis library is tested with all current LTS versions of Node - **18**, and **20**.\n\n## Install\n\n```\nnpm install stytch\n# or\nyarn add stytch\n```\n\n## Usage\n\nYou can find your API credentials in the [Stytch Dashboard](https://stytch.com/dashboard/api-keys).\n\nThis client library supports all of Stytch's live products:\n\n**B2C**\n\n- [x] [Email Magic Links](https://stytch.com/docs/api/send-by-email)\n- [x] [Embeddable Magic Links](https://stytch.com/docs/api/create-magic-link)\n- [x] [OAuth logins](https://stytch.com/docs/api/oauth-google-start)\n- [x] [SMS passcodes](https://stytch.com/docs/api/send-otp-by-sms)\n- [x] [WhatsApp passcodes](https://stytch.com/docs/api/whatsapp-send)\n- [x] [Email passcodes](https://stytch.com/docs/api/send-otp-by-email)\n- [x] [Session Management](https://stytch.com/docs/api/session-auth)\n- [x] [WebAuthn](https://stytch.com/docs/api/webauthn-register-start)\n- [x] [User Management](https://stytch.com/docs/api/create-user)\n- [x] [Time-based one-time passcodes (TOTPs)](https://stytch.com/docs/api/totp-create)\n- [x] [Crypto wallets](https://stytch.com/docs/api/crypto-wallet-authenticate-start)\n- [x] [Passwords](https://stytch.com/docs/api/password-create)\n\n**B2B**\n\n- [x] [Organizations](https://stytch.com/docs/b2b/api/organization-object)\n- [x] [Members](https://stytch.com/docs/b2b/api/member-object)\n- [x] [RBAC](https://stytch.com/docs/b2b/api/rbac-resource-object)\n- [x] [Email Magic Links](https://stytch.com/docs/b2b/api/send-login-signup-email)\n- [x] [OAuth logins](https://stytch.com/docs/b2b/api/oauth-google-start)\n- [x] [Session Management](https://stytch.com/docs/b2b/api/session-object)\n- [x] [Single-Sign On](https://stytch.com/docs/b2b/api/sso-authenticate-start)\n- [x] [Discovery](https://stytch.com/docs/b2b/api/discovered-organization-object)\n- [x] [Passwords](https://stytch.com/docs/b2b/api/passwords-authenticate)\n- [x] [SMS OTP (MFA)](https://stytch.com/docs/b2b/api/otp-sms-send)\n- [x] [M2M](https://stytch.com/docs/b2b/api/m2m-client)\n\n**Shared**\n\n- [x] [M2M](https://stytch.com/docs/api/m2m-client)\n\n### Example B2C usage\n\nCreate an API client:\n\n```javascript\nconst stytch = require(\"stytch\");\n// Or as an ES6 module:\n// import * as stytch from \"stytch\";\n\nconst client = new stytch.Client({\n  project_id: \"project-live-c60c0abe-c25a-4472-a9ed-320c6667d317\",\n  secret: \"secret-live-80JASucyk7z_G8Z-7dVwZVGXL5NT_qGAQ2I=\",\n});\n```\n\nSend a magic link by email:\n\n```javascript\nclient.magicLinks.email\n  .loginOrCreate({\n    email: \"sandbox@stytch.com\",\n    login_magic_link_url: \"https://example.com/authenticate\",\n    signup_magic_link_url: \"https://example.com/authenticate\",\n  })\n  .then((res) =\u003e console.log(res))\n  .catch((err) =\u003e console.error(err));\n```\n\nAuthenticate the token from the magic link:\n\n```javascript\nclient.magicLinks\n  .authenticate({ token: \"DOYoip3rvIMMW5lgItikFK-Ak1CfMsgjuiCyI7uuU94=\" })\n  .then((res) =\u003e console.log(res))\n  .catch((err) =\u003e console.error(err));\n```\n\n### Example B2B usage\n\nCreate an API client:\n\n```javascript\nconst stytch = require(\"stytch\");\n// Or as an ES6 module:\n// import * as stytch from \"stytch\";\n\nconst client = new stytch.B2BClient({\n  project_id: \"project-live-c60c0abe-c25a-4472-a9ed-320c6667d317\",\n  secret: \"secret-live-80JASucyk7z_G8Z-7dVwZVGXL5NT_qGAQ2I=\",\n});\n```\n\nCreate an organization\n\n```javascript\nclient.organizations\n  .create({\n    organization_name: \"Acme Co\",\n    organization_slug: \"acme-co\",\n    email_allowed_domains: [\"acme.co\"],\n  })\n  .then((res) =\u003e console.log(res))\n  .catch((err) =\u003e console.error(err));\n```\n\nLog the first user into the organization\n\n```javascript\nclient.magicLinks\n  .loginOrSignup({\n    organization_id: \"organization-id-from-create-response-...\",\n    email_address: \"admin@acme.co\",\n  })\n  .then((res) =\u003e console.log(res))\n  .catch((err) =\u003e console.error(err));\n```\n\n## TypeScript support\n\nThis package includes TypeScript declarations for the Stytch API.\n\nRequest and response types will always follow the format `$Vertical$Product$Method(Request|Response)` -\nfor example the `B2BMagicLinksAuthenticateRequest` maps to the B2B\n[Authenticate Magic Link](https://stytch.com/docs/b2b/api/authenticate-magic-link) endpoint, while the\n`B2CMagicLinksAuthenticateRequest` maps to the B2C [Authenticate Magic Link](https://stytch.com/docs/api/authenticate-magic-link) endpoint.\n\n## Handling Errors\n\nStytch errors always include an `error_type` field you can use to identify them:\n\n```javascript\nclient.magicLinks\n  .authenticate({ token: \"not-a-token!\" })\n  .then((res) =\u003e console.log(res))\n  .catch((err) =\u003e {\n    if (err.error_type === \"invalid_token\") {\n      console.log(\"Whoops! Try again?\");\n    }\n  });\n```\n\nLearn more about errors in the [docs](https://stytch.com/docs/api/errors).\n\n## Customizing the HTTPS Agent\n\nThe Stytch client uses [undici](https://github.com/nodejs/undici), the Node fetch implementation. You can pass a custom undici `Dispatcher` to the client for use in requests.\nFor example, you can enable HTTPS Keep-Alive to avoid the cost of establishing a new connection with the Stytch servers on every request.\n\n```javascript\nconst dispatcher = new undici.Agent({\n  keepAliveTimeout: 6e6, // 10 minutes in MS\n  keepAliveMaxTimeout: 6e6, // 10 minutes in MS\n});\n\nconst client = new stytch.Client({\n  project_id: \"project-live-c60c0abe-c25a-4472-a9ed-320c6667d317\",\n  secret: \"secret-live-80JASucyk7z_G8Z-7dVwZVGXL5NT_qGAQ2I=\",\n  dispatcher,\n});\n```\n\n## Documentation\n\nSee example requests and responses for all the endpoints in the [Stytch API Reference](https://stytch.com/docs/api).\n\nFollow one of the [integration guides](https://stytch.com/docs/guides) or start with one of our [example apps](https://stytch.com/docs/example-apps).\n\n## Support\n\nIf you've found a bug, [open an issue](https://github.com/stytchauth/stytch-node/issues/new)!\n\nIf you have questions or want help troubleshooting, join us in [Slack](https://stytch.com/docs/resources/support/overview) or email support@stytch.com.\n\nIf you've found a security vulnerability, please follow our [responsible disclosure instructions](https://stytch.com/docs/resources/security-and-trust/security#:~:text=Responsible%20disclosure%20program).\n\n## Development\n\nSee [DEVELOPMENT.md](DEVELOPMENT.md)\n\n## Code of Conduct\n\nEveryone interacting in the Stytch project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstytchauth%2Fstytch-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstytchauth%2Fstytch-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstytchauth%2Fstytch-node/lists"}