Skip to content

Commit a348cca

Browse files
authored
doc: tweak auth/sveltekit lazy initialization doc (#10784)
1 parent d923192 commit a348cca

File tree

1 file changed

+6
-7
lines changed
  • packages/frameworks-sveltekit/src/lib

1 file changed

+6
-7
lines changed

packages/frameworks-sveltekit/src/lib/index.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,32 @@
1818
*
1919
* import { SvelteKitAuth } from "@auth/sveltekit"
2020
* import GitHub from "@auth/sveltekit/providers/github"
21-
* import { GITHUB_ID, GITHUB_SECRET } from "$env/static/private"
2221
*
2322
* export const { handle, signIn, signOut } = SvelteKitAuth({
24-
* providers: [GitHub({ clientId: GITHUB_ID, clientSecret: GITHUB_SECRET })],
23+
* providers: [GitHub],
2524
* })
2625
* ```
2726
*
28-
* or to use SvelteKit platform environment variables for platforms like Cloudflare
27+
* ### Lazy initialization
28+
* `@auth/sveltekit` supports lazy initialization where you can read the `event` object to lazily set the configuration. This is especially useful when you have to get the environment variables from `event.platform` for platforms like Cloudflare Workers.
2929
*
3030
* ```ts title="src/auth.ts"
3131
* import { SvelteKitAuth } from "@auth/sveltekit"
3232
* import GitHub from "@auth/sveltekit/providers/github"
33-
* import type { Handle } from "@sveltejs/kit";
3433
*
3534
* export const { handle, signIn, signOut } = SvelteKitAuth(async (event) => {
3635
* const authOptions = {
3736
* providers: [
3837
* GitHub({
39-
* clientId: event.platform.env.GITHUB_ID,
40-
* clientSecret: event.platform.env.GITHUB_SECRET
38+
* clientId: event.platform.env.AUTH_GITHUB_ID,
39+
* clientSecret: event.platform.env.AUTH_GITHUB_SECRET
4140
* })
4241
* ],
4342
* secret: event.platform.env.AUTH_SECRET,
4443
* trustHost: true
4544
* }
4645
* return authOptions
47-
* }) satisfies Handle;
46+
* })
4847
* ```
4948
*
5049
* Re-export the handle in `src/hooks.server.ts`:

0 commit comments

Comments
 (0)