0
Fork 0
mirror of https://github.com/TanStack/router.git synced 2026-11-16 19:38:07 +00:00
router/examples/react/start-workos
Manuel Schiller 15b8ed6af3
chore: various fixes (#4187)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
History 2025-05-16 19:51:24 +02:00
..
.tanstack-start/server-routes Devinxi (#4111) 2025-05-10 14:54:51 +02:00
src chore: various fixes (#4187) 2025-05-16 19:51:24 +02:00
.env.example chore(examples): add TanStack Start WorkOS example (#3966) 2025-04-10 20:41:57 +12:00
.gitignore Devinxi (#4111) 2025-05-10 14:54:51 +02:00
.prettierignore Devinxi (#4111) 2025-05-10 14:54:51 +02:00
package.json release: v1.120.4-alpha.25 2025-05-16 12:53:27 +00:00
prettier.config.js chore(examples): add TanStack Start WorkOS example (#3966) 2025-04-10 20:41:57 +12:00
README.md chore(examples): add TanStack Start WorkOS example (#3966) 2025-04-10 20:41:57 +12:00
tsconfig.json chore(examples): add TanStack Start WorkOS example (#3966) 2025-04-10 20:41:57 +12:00
vite.config.ts Devinxi (#4111) 2025-05-10 14:54:51 +02:00

TanStack Start + WorkOS

This site is built with TanStack Router! An example application demonstrating how to authenticate users with AuthKit and the WorkOS Node SDK.

Prerequisites

You will need a WorkOS account.

Running the example

  1. In the WorkOS dashboard, click on the User Management tile and set up the sign-in callback redirect as http://localhost:3000/api/auth/callback. Once completed, set the app homepage URL to http://localhost:3000.

    Note

    If you already have set up an application in your WorkOS dashboard, then you can simply head to the Redirects tab and add a new redirect URI.

  2. After creating the redirect URI, navigate to the API keys tab and copy the Client ID and the Secret Key. Rename the .env.example file to .env and supply your Client ID and API key as environment variables.

  3. Additionally, create a cookie password as the private key used to encrypt the session cookie. Copy the output into the environment variable WORKOS_COOKIE_PASSWORD.

    It has to be at least 32 characters long. You can use https://1password.com/password-generator/ to generate strong passwords.

  4. Verify your .env.local file has the following variables filled.

    WORKOS_CLIENT_ID=<YOUR_CLIENT_ID>
    WORKOS_API_KEY=<YOUR_API_SECRET_KEY>
    WORKOS_COOKIE_PASSWORD=<YOUR_COOKIE_PASSWORD>
    WORKOS_REDIRECT_URI=http://localhost:3000/callback
    

    WORKOS_COOKIE_PASSWORD is the private key used to encrypt the session cookie. It has to be at least 32 characters long. You can use the 1Password generator or the openssl library to generate a strong password via the command line:

    openssl rand -base64 24
    

    To use the signOut method, you'll need to set a default Logout URI in your WorkOS dashboard settings under "Redirects".

  5. Run the following command and navigate to http://localhost:3000.

    pnpm dev