https://github.com/workos/react-router-authkit-example
https://github.com/workos/react-router-authkit-example
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/workos/react-router-authkit-example
- Owner: workos
- License: mit
- Created: 2025-03-10T21:07:26.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-15T15:23:31.000Z (about 1 year ago)
- Last Synced: 2025-06-02T23:27:41.073Z (about 1 year ago)
- Language: TypeScript
- Size: 490 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# React Router integration example using AuthKit
An example application demonstrating how to authenticate users with AuthKit and the authkit-react-router helper library.
> Refer to the [User Management](https://workos.com/docs/user-management) documentation for reference.
## Prerequisites
You will need a [WorkOS account](https://dashboard.workos.com/signup).
## Requirements
Node v18 or higher
## Running the example
Rename the `.env.example` file to `.env` and supply your Client ID and API key as environment variables. The client ID and API key can be found in the [WorkOS dashboard](https://dashboard.workos.com/), and the redirect URI can also be configured there.
```sh
WORKOS_CLIENT_ID=client_... # retrieved from the WorkOS dashboard
WORKOS_API_KEY=sk_test_... # retrieved from the WorkOS dashboard
WORKOS_REDIRECT_URI=http://localhost:5173/callback # configured in the WorkOS dashboard
WORKOS_COOKIE_PASSWORD= # generate a secure password here
```
`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:
```
openssl rand -base64 24
```
Install the dependencies
```bash
npm install
```
Run the following command and navigate to [http://localhost:5173](http://localhost:5173).
```bash
npm run dev
```