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
History 2025-10-29 22:25:20 +00:00
..
src fix: opt into SSR type level serializability check (#5233) 2025-09-25 17:28:40 +02:00
.env.example chore(examples): add TanStack Start WorkOS example (#3966) 2025-04-10 20:41:57 +12:00
.gitignore feat: Merge alpha to main (#4365) 2025-06-10 23:19:32 +02:00
.prettierignore feat: Merge alpha to main (#4365) 2025-06-10 23:19:32 +02:00
package.json release: v1.134.0 2025-10-29 22:25:20 +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 feat: Start RC (#5189) 2025-09-23 11:34:54 -06: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