{"id":21096794,"url":"https://github.com/stytchauth/stytch-b2b-node-example","last_synced_at":"2025-08-09T00:10:59.256Z","repository":{"id":75703551,"uuid":"598879336","full_name":"stytchauth/stytch-b2b-node-example","owner":"stytchauth","description":"An example of Stytch's B2B authentication suite in a Next.js application ","archived":false,"fork":false,"pushed_at":"2025-04-14T23:46:15.000Z","size":2169,"stargazers_count":37,"open_issues_count":17,"forks_count":6,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-07-30T03:41:19.297Z","etag":null,"topics":["nextjs","saml","sso","stytch"],"latest_commit_sha":null,"homepage":"https://www.stytchb2bdemo.app/","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":null,"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,"zenodo":null}},"created_at":"2023-02-08T01:34:24.000Z","updated_at":"2025-04-14T23:46:20.000Z","dependencies_parsed_at":"2024-03-09T01:23:57.755Z","dependency_job_id":"f4fac09c-978f-41a6-ad9b-64105723fde5","html_url":"https://github.com/stytchauth/stytch-b2b-node-example","commit_stats":null,"previous_names":["stytchauth/stytch-b2b-node-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stytchauth/stytch-b2b-node-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stytchauth%2Fstytch-b2b-node-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stytchauth%2Fstytch-b2b-node-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stytchauth%2Fstytch-b2b-node-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stytchauth%2Fstytch-b2b-node-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stytchauth","download_url":"https://codeload.github.com/stytchauth/stytch-b2b-node-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stytchauth%2Fstytch-b2b-node-example/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269508722,"owners_count":24428745,"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","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["nextjs","saml","sso","stytch"],"created_at":"2024-11-19T22:43:52.909Z","updated_at":"2025-08-09T00:10:59.199Z","avatar_url":"https://github.com/stytchauth.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stytch B2B backend Node example\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"787\" alt=\"image\" src=\"https://github.com/stytchauth/stytch-b2b-node-example/assets/113396792/1c374141-b72f-4706-aaf7-bd71247b7c39\"\u003e\n\u003c/p\u003e\n\n## Overview\n\nThis example application demonstrates how to use Stytch's B2B authentication suite using our [backend Node SDK](https://www.npmjs.com/package/stytch) inside of a Next.js application. The application features both Discovery and Organization B2B login flows, you can try out a hosted version of this app on Vercel at [https://www.stytchb2bdemo.app/](https://www.stytchb2bdemo.app/).\n\nUsing the Discovery flow, users can log in via Email Magic Links, Google OAuth, or Microsoft OAuth, and can join existing Organizations that they have access to or create new ones. Using the Organization flow, users can log into a specific Organization that they belong to via Email Magic Links, Google OAuth, Microsoft OAuth, or SSO.\n\nOn this example application's profile page, Organization admins are able to invite other Members to the Organization and can set up SSO connections via SAML or OIDC.\n\nThis project was bootstrapped with [Create Next App](https://nextjs.org/docs/api-reference/create-next-app).\n\n## Setup\n\nFollow the below steps below to run this application using your own Stytch API keys.\n\n### In the Stytch Dashboard\n\n1. Create a [Stytch](https://stytch.com/) account. During the signup flow, select **B2B Authentication**. Once your account is set up, a project called \"My first project\" will be created for you.\n\n   - If you signed up for Stytch in the past, then your default project is likely a Consumer project. You can confirm this in your [Project settings](https://stytch.com/dashboard/project-settings). To create a B2B project, use the Project dropdown near the top of the dashboard side nav. Be sure to select **B2B Authentication** as the authentication type.\n\n2. Navigate to [Redirect URLs](https://stytch.com/dashboard/redirect-urls), and add `http://localhost:3000/api/callback` as the types **Login**, **Sign-up**, **Discovery** and **Invite**.\n\n   \u003cimg width=\"500\" alt=\"UI to add an allowlisted Redirect URL\" src=\"https://github.com/stytchauth/stytch-b2b-nextjs-example/assets/113396792/bb9f6616-8c06-44bd-846b-6ae91a5b5d69\"\u003e\n\n3. Finally, navigate to [API Keys](https://stytch.com/dashboard/api-keys). You will need the `project_id`, `secret`, and `public_token` values found on this page.\n\n### On your machine\n\nIn your terminal, clone the project and install dependencies:\n\n```bash\ngit clone https://github.com/stytchauth/stytch-b2b-node-example.git\ncd stytch-b2b-node-example\npnpm install\n```\n\nNext, create an `.env.local` file by running the command below, which copies the contents of `.env.template`.\n\n```bash\ncp .env.template .env.local\n```\n\nOpen `.env.local` in the text editor of your choice, and set the environment variables using the `project_id`, `secret`, and `public_token` found on the [API Keys](https://stytch.com/dashboard/api-keys) page. Leave the `NEXT_PUBLIC_STYTCH_PROJECT_ENV` value as `test`.\n\n```\n# This is what a completed .env.local file will look like\nNEXT_PUBLIC_STYTCH_PROJECT_ENV=test\nSTYTCH_PROJECT_ID=project-test-00000000-0000-1234-abcd-abcdef1234\nSTYTCH_SECRET=secret-test-12345678901234567890abcdabcd\nNEXT_PUBLIC_STYTCH_PUBLIC_TOKEN=public-token-test-abc123-abcde-1234-0987-0000-abcd1234\n```\n\n## Running locally\n\nAfter completing all of the above steps, the application can be run with the command:\n\n```bash\npnpm run dev\n```\n\nThe application will be available at [`http://localhost:3000`](http://localhost:3000).\n\n## Get help and join the community\n\n#### :speech_balloon: Stytch community Slack\n\nJoin the discussion, ask questions, and suggest new features in our [Slack community](https://stytch.com/docs/b2b/resources/support/overview)!\n\n#### :question: Need support?\n\nCheck out the [Stytch Forum](https://forum.stytch.com/) or email us at [support@stytch.com](mailto:support@stytch.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstytchauth%2Fstytch-b2b-node-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstytchauth%2Fstytch-b2b-node-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstytchauth%2Fstytch-b2b-node-example/lists"}