Skip to content

Commit c6a8f2e

Browse files
committed
Increase copy-paste-ability of README examples
Add text (similar to PHP example) to rename `.env.example` to `.env`. Change port from `:3000` to `:5173`. This is vite standard and default for new Remix apps. Replace (unused) `useRouteLoaderData` with `useLoaderData`. Remove unused variables from returned `withAuth` object to eleminate errors. (Left them as a comment). Add `<br />` between `Sign in` and `Sign out` for visual separation.
1 parent bee1b90 commit c6a8f2e

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

README.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ yarn add @workos-inc/authkit-remix
1818

1919
## Pre-flight
2020

21-
Make sure the following values are present in your `.env.local` environment variables file. 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.
21+
Rename the `.env.example` file to `.env` and ensure the following values are present in it. 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.
2222

2323
```sh
2424
WORKOS_CLIENT_ID="client_..." # retrieved from the WorkOS dashboard
2525
WORKOS_API_KEY="sk_test_..." # retrieved from the WorkOS dashboard
26-
WORKOS_REDIRECT_URI="http://localhost:3000/callback" # configured in the WorkOS dashboard
26+
WORKOS_REDIRECT_URI="http://localhost:5173/callback" # configured in the WorkOS dashboard
2727
WORKOS_COOKIE_PASSWORD="<your password>" # generate a secure password here
2828
```
2929

@@ -43,7 +43,7 @@ Certain environment variables are optional and can be used to debug or configure
4343
WORKOS_COOKIE_MAX_AGE='600' # maximum age of the cookie in seconds. Defaults to 31 days
4444
WORKOS_API_HOSTNAME='api.workos.com' # base WorkOS API URL
4545
WORKOS_API_HTTPS=true # whether to use HTTPS in API calls
46-
WORKOS_API_PORT=3000 # port to use for API calls
46+
WORKOS_API_PORT=5173 # port to use for API calls
4747
```
4848

4949
## Setup
@@ -58,7 +58,7 @@ import { authLoader } from '@workos-inc/authkit-remix';
5858
export const loader = authLoader();
5959
```
6060

61-
Make sure this route matches the `WORKOS_REDIRECT_URI` variable and the configured redirect URI in your WorkOS dashboard. For instance if your redirect URI is `http://localhost:3000/callback` then you'd put the above code in `/app/routes/callback.ts`.
61+
Make sure this route matches the `WORKOS_REDIRECT_URI` variable and the configured redirect URI in your WorkOS dashboard. For instance if your redirect URI is `http://localhost:5173/callback` then you'd put the above code in `/app/routes/callback.ts`.
6262

6363
You can also control the pathname the user will be sent to after signing-in by passing a `returnPathname` option to `authLoader` like so:
6464

@@ -74,18 +74,12 @@ For pages where you want to display a signed-in and signed-out view, use `withAu
7474

7575
```jsx
7676
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node';
77-
import { Link, useRouteLoaderData, json, Form } from '@remix-run/react';
77+
import { Link, useLoaderData, json, Form } from '@remix-run/react';
7878
import { getSignInUrl, getSignUpUrl, withAuth, signOut } from '@workos-inc/authkit-remix';
7979

80-
export async function loader({ request }: LoaderFunctionArgs) {
81-
const {
82-
user,
83-
sessionId,
84-
organizationId,
85-
role,
86-
impersonator,
87-
accessToken
88-
} = await withAuth(request);
80+
export async function loader({request}: LoaderFunctionArgs) {
81+
// additional properties include: sessionId, organizationId, role, impersonator, accessToken
82+
const {user} = await withAuth(request);
8983

9084
return json({
9185
signInUrl: await getSignInUrl(),
@@ -106,6 +100,7 @@ export default function HomePage() {
106100
return (
107101
<>
108102
<Link to={signInUrl}>Log in</Link>
103+
<br />
109104
<Link to={signUpUrl}>Sign Up</Link>
110105
</>
111106
);

0 commit comments

Comments
 (0)