Open History to see the last commit
1# TanStack Start + WorkOS
2β
3This site is built with TanStack Router! An example application demonstrating how to authenticate users with AuthKit and the WorkOS Node SDK.
4β
5- [TanStack Router Docs](https://tanstack.com/router)
6β
7## Prerequisites
8β
9You will need a [WorkOS account](https://dashboard.workos.com/signup).
10β
11## Running the example
12β
131. In the [WorkOS dashboard](https://dashboard.workos.com), click on the User Management tile and set up the [sign-in callback redirect](https://workos.com/docs/user-management/1-configure-your-project/configure-a-redirect-uri) as `http://localhost:3000/api/auth/callback`. Once completed, set the app homepage URL to `http://localhost:3000`.
14β
15 > [!NOTE]
16 > 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.
17β
182. 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.
19β
203. 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`.
21β
22 It has to be at least 32 characters long. You can use https://1password.com/password-generator/ to generate strong passwords.
23β
244. Verify your `.env.local` file has the following variables filled.
25β
26 ```bash
27 WORKOS_CLIENT_ID=<YOUR_CLIENT_ID>
28 WORKOS_API_KEY=<YOUR_API_SECRET_KEY>
29 WORKOS_COOKIE_PASSWORD=<YOUR_COOKIE_PASSWORD>
30 WORKOS_REDIRECT_URI=http://localhost:3000/callback
31 ```
32β
33 `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](https://1password.com/password-generator/) or the `openssl` library to generate a strong password via the command line:
34β
35 ```bash
36 openssl rand -base64 24
37 ```
38β
39 To use the `signOut` method, you'll need to set a default Logout URI in your WorkOS dashboard settings under "Redirects".
40β
415. Run the following command and navigate to [http://localhost:3000](http://localhost:3000).
42β
43 ```bash
44 pnpm dev
45 ```