|
2 | 2 |
|
3 | 3 | An example application demonstrating how to authenticate users with AuthKit and the WorkOS Node SDK.
|
4 | 4 |
|
5 |
| -## Project setup |
| 5 | +> Refer to the [User Management](https://workos.com/docs/user-management) documentation for reference. |
6 | 6 |
|
7 |
| -To get started, clone the repo: |
| 7 | +## Prerequisites |
8 | 8 |
|
9 |
| -```bash |
10 |
| -git clone https://github.com/workos/next-authkit-example.git |
11 |
| -``` |
| 9 | +You will need a [WorkOS account](https://dashboard.workos.com/signup). |
12 | 10 |
|
13 |
| -Navigate to the cloned repo and install the dependencies: |
| 11 | +## Running the example |
14 | 12 |
|
15 |
| -```bash |
16 |
| -npm install |
17 |
| -``` |
| 13 | +1. In the [WorkOS dashboard](https://dashboard.workos.com), head to the Redirects tab and create a [sign-in callback redirect](https://workos.com/docs/user-management/1-configure-your-project/configure-a-redirect-uri) for `http://localhost:3000/callback`. |
18 | 14 |
|
19 |
| -## Getting started with WorkOS |
| 15 | +2. After creating the redirect URI, navigate to the API keys tab and copy the _Client ID_ and the _Secret Key_. Rename the `.env.local.example` file to `.env.local` and supply your Client ID and API key as environment variables. |
20 | 16 |
|
21 |
| -Sign up for a [WorkOS account](https://dashboard.workos.com/signup), log in, navigate to the API keys tab and copy the _Client ID_ and the _Secret Key_. |
| 17 | +3. Additionally, [create a signing secret](https://workos.com/docs/user-management/3-handle-the-user-session/create-a-signing-secret) by running the below command. Copy the output into the environment variable `JWT_SECRET_KEY`. |
22 | 18 |
|
23 |
| -Rename the `.env.local.example` file to `.env.local` and supply your Client ID and API key. |
| 19 | + ```bash |
| 20 | + node -e "console.log(require('crypto').randomBytes(64).toString('base64'));" |
| 21 | + ``` |
24 | 22 |
|
25 |
| -Finally, start the development environment and navigate to http://localhost:3000. |
| 23 | +4. Verify your `.env.local` file has the following variables filled. |
26 | 24 |
|
27 |
| -```bash |
28 |
| -npm run dev |
29 |
| -``` |
| 25 | + ```bash |
| 26 | + WORKOS_CLIENT_ID=<YOUR_CLIENT_ID> |
| 27 | + WORKOS_API_KEY=<YOUR_API_SECRET_KEY> |
| 28 | + WORKOS_REDIRECT_URI=http://localhost:3000/callback |
| 29 | + JWT_SECRET_KEY=<YOUR_JWT_SECRET_KEY> |
| 30 | + ``` |
| 31 | + |
| 32 | +5. Run the following command and navigate to [http://localhost:3000](http://localhost:3000). |
| 33 | + |
| 34 | + ```bash |
| 35 | + npm run dev |
| 36 | + ``` |
0 commit comments