Skip to content

Commit 809cc26

Browse files
committed
README updates
1 parent 3b219a3 commit 809cc26

File tree

1 file changed

+51
-5
lines changed

1 file changed

+51
-5
lines changed

README.md

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ export const load = authKit.withAuth(async ({ auth }) => {
8888
// auth.user is guaranteed to exist
8989
return {
9090
user: auth.user,
91-
organization: auth.organization
91+
organizationId: auth.organizationId,
92+
role: auth.role,
93+
permissions: auth.permissions
9294
};
9395
});
9496
```
@@ -122,7 +124,19 @@ Get the WorkOS sign-in URL.
122124
```typescript
123125
const signInUrl = authKit.getSignInUrl({
124126
returnTo: '/dashboard',
125-
organizationId: 'org_123' // optional
127+
organizationId: 'org_123', // optional
128+
loginHint: 'user@example.com' // optional
129+
});
130+
```
131+
132+
#### `authKit.getSignUpUrl(options)`
133+
Get the WorkOS sign-up URL.
134+
135+
```typescript
136+
const signUpUrl = authKit.getSignUpUrl({
137+
returnTo: '/dashboard',
138+
organizationId: 'org_123', // optional
139+
loginHint: 'user@example.com' // optional
126140
});
127141
```
128142

@@ -149,7 +163,19 @@ export const handle = authKitHandle({
149163
});
150164
```
151165

152-
## Configuration Options
166+
## Configuration
167+
168+
```typescript
169+
interface AuthKitConfig {
170+
clientId: string; // WorkOS Client ID
171+
apiKey: string; // WorkOS API Key
172+
redirectUri: string; // OAuth redirect URI
173+
cookiePassword: string; // Cookie encryption password (min 32 chars)
174+
cookieName?: string; // Custom cookie name (default: 'wos-session')
175+
cookieDomain?: string; // Cookie domain restriction
176+
cookieMaxAge?: number; // Cookie max age in seconds (default: 400 days)
177+
}
178+
```
153179

154180
### Environment Variables
155181

@@ -222,10 +248,26 @@ export const actions = {
222248
<script lang="ts">
223249
import { authKit } from '@workos/authkit-sveltekit';
224250
225-
const signInUrl = authKit.getSignInUrl({ returnTo: '/dashboard' });
251+
// Note: These methods are async and should be called server-side
252+
// For client-side, pass the URL from a server load function
226253
</script>
227254
228-
<a href={signInUrl}>Sign In</a>
255+
<!-- Use URLs generated server-side -->
256+
<a href={data.signInUrl}>Sign In</a>
257+
<a href={data.signUpUrl}>Sign Up</a>
258+
```
259+
260+
Server-side load function:
261+
```typescript
262+
// +page.server.ts
263+
import { authKit } from '@workos/authkit-sveltekit';
264+
265+
export const load = async () => {
266+
return {
267+
signInUrl: await authKit.getSignInUrl({ returnTo: '/dashboard' }),
268+
signUpUrl: await authKit.getSignUpUrl({ returnTo: '/dashboard' })
269+
};
270+
};
229271
```
230272

231273
### Form Actions
@@ -252,6 +294,10 @@ export const load: PageServerLoad = async ({ locals }) => {
252294
if (locals.auth.user) {
253295
// TypeScript knows user exists and its shape
254296
console.log(locals.auth.user.email);
297+
console.log(locals.auth.organizationId);
298+
console.log(locals.auth.role);
299+
console.log(locals.auth.permissions);
300+
console.log(locals.auth.accessToken);
255301
}
256302
};
257303
```

0 commit comments

Comments
 (0)