Skip to content

Commit e98cea8

Browse files
committed
docs: 📝 update useage doc
1 parent 8f97aec commit e98cea8

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

+31
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,37 @@ export const handle = sequence(
8989
);
9090
```
9191

92+
Then, add a login handler `src/routes/auth/[provider]/+server.ts`:
93+
94+
```ts
95+
import { redirect, type RequestEvent } from '@sveltejs/kit';
96+
97+
export const GET = async (event: RequestEvent) => {
98+
const { request } = event;
99+
const provider = event.params.provider ?? 'github';
100+
return await event.locals.auth.authenticate(event, provider, {
101+
successRedirect: '/dashboard',
102+
failureRedirect: '/error'
103+
});
104+
};
105+
```
106+
107+
Finally, add a callback handler `src/routes/auth/[provider]/callback/+server.ts.ts`:
108+
109+
```ts
110+
// same as before...
111+
import type { RequestEvent } from '@sveltejs/kit';
112+
113+
export const GET = async (event: RequestEvent) => {
114+
const provider = event.params.provider ?? 'github';
115+
116+
return await event.locals.auth.authenticate(event, provider, {
117+
successRedirect: '/dashboard',
118+
failureRedirect: '/error'
119+
});
120+
};
121+
```
122+
92123
## Advanced Usage
93124

94125
### Typescript

0 commit comments

Comments
 (0)