Skip to content

Commit a3d3d4b

Browse files
authored
docs: add Qwik documentation (#11346)
* feat: add Qwik getting started * feat: add QwikCode * feat: update providers with Qwik code * feat: update adapters with Qwik code * fix: update dev example * fix: update OAuthProviderInstructions * feat: update guides pages with Qwik code * feat: update getting-started with Qwik code
1 parent f278079 commit a3d3d4b

File tree

128 files changed

+3203
-8
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+3203
-8
lines changed

apps/dev/qwik/src/routes/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ export default component$(() => {
1919
<input type="hidden" name="providerId" value="github" />
2020
<input
2121
type="hidden"
22-
name="options.callbackUrl"
22+
name="options.redirectTo"
2323
value="http://qwik-auth-example.com/dashboard"
2424
/>
2525
<button>Sign In</button>
2626
</Form>
2727
Session: {JSON.stringify(session.value)}
2828
<br />
29-
<button onClick$={() => signOut.submit({ callbackUrl: "/" })}>
29+
<button onClick$={() => signOut.submit({ redirectTo: "/" })}>
3030
Sign Out
3131
</button>
3232
</>

docs/components/Code/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { useThemeConfig } from "nextra-theme-docs"
21
import { useRouter } from "next/router"
2+
import { useThemeConfig } from "nextra-theme-docs"
33
import { Tabs } from "nextra/components"
44
import React, { Children, useEffect, useState } from "react"
55

@@ -14,9 +14,11 @@ Code.NextClient = NextClientCode
1414
Code.Svelte = SvelteCode
1515
// Code.Solid = SolidCode;
1616
Code.Express = ExpressCode
17+
Code.Qwik = QwikCode
1718

1819
const baseFrameworks = {
1920
[NextCode.name]: "Next.js",
21+
[QwikCode.name]: "Qwik",
2022
[SvelteCode.name]: "SvelteKit",
2123
[ExpressCode.name]: "Express",
2224
// [SolidCode.name]: "SolidStart",
@@ -25,6 +27,7 @@ const baseFrameworks = {
2527
const allFrameworks = {
2628
[NextCode.name]: "Next.js",
2729
[NextClientCode.name]: "Next.js (Client)",
30+
[QwikCode.name]: "Qwik",
2831
[SvelteCode.name]: "SvelteKit",
2932
// [SolidCode.name]: "SolidStart",
3033
[ExpressCode.name]: "Express",
@@ -124,3 +127,7 @@ function SvelteCode({ children }: ChildrenProps) {
124127
function ExpressCode({ children }: ChildrenProps) {
125128
return <Tabs.Tab>{children}</Tabs.Tab>
126129
}
130+
131+
function QwikCode({ children }: ChildrenProps) {
132+
return <Tabs.Tab>{children}</Tabs.Tab>
133+
}

docs/components/OAuthProviderInstructions/content/components/SetupCode.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,26 @@ export const { GET, POST } = handlers
4949
}}
5050
/>
5151
</Code.Next>
52+
<Code.Qwik>
53+
We recommend setting up your configuration in{" "}
54+
<code>/src/routes/[email protected]</code> file.
55+
<Pre
56+
data-filename="/src/routes/[email protected]"
57+
data-theme="default"
58+
data-copy=""
59+
data-language="tsx"
60+
icon={TSIcon}
61+
dangerouslySetInnerHTML={{
62+
__html: highlight(`
63+
import { SvelteKitAuth } from "@auth/sveltekit"
64+
import ${providerName} from "@auth/sveltekit/providers/${providerId}"
65+
66+
export const { handle, signIn, signOut } = SvelteKitAuth({
67+
providers: [${providerName}],
68+
}) `),
69+
}}
70+
/>
71+
</Code.Qwik>
5272
<Code.Svelte>
5373
In SvelteKit you should also setup your Auth.js configuration in a file
5474
at <code>/src/auth.ts</code>.

docs/components/OAuthProviderInstructions/content/components/SignInCode.tsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,49 @@ export function SignIn() {
3737
}}
3838
/>
3939
</Code.Next>
40+
<Code.Qwik>
41+
With Qwik we can do a server-side login with Form action, or a more
42+
simple client-side login via submit method.
43+
<Pre
44+
data-filename="./components/sign-in.tsx"
45+
data-theme="default"
46+
data-copy=""
47+
data-language="tsx"
48+
icon={TSIcon}
49+
dangerouslySetInnerHTML={{
50+
__html: highlight(`
51+
import { component$ } from "@builder.io/qwik"
52+
import { Form } from "@builder.io/qwik-city"
53+
import { useSignIn } from "./plugin@auth"
54+
55+
export default component$(() => {
56+
const signInSig = useSignIn()
57+
58+
return (
59+
<>
60+
{/* server-side login with Form action */}
61+
<Form action={signInSig}>
62+
<input type="hidden" name="providerId" value="${providerId}" />
63+
<input
64+
type="hidden"
65+
name="options.redirectTo"
66+
value="/"
67+
/>
68+
<button>Sign In</button>
69+
</Form>
70+
71+
{/* submit method */}
72+
<Link
73+
onClick$={() => signInSig.submit({ redirectTo: "/" })}
74+
>
75+
SignIn
76+
</Link>
77+
</>
78+
)
79+
}) `),
80+
}}
81+
/>
82+
</Code.Qwik>
4083
<Code.Svelte>
4184
With SvelteKit we can do a server-side login with Form Actions, or a
4285
more simple client-side login via links and redirects.

docs/components/OAuthProviderInstructions/content/index.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ export function OAuthInstructions({ providerId, disabled = false }: Props) {
7575
</NXCode>
7676
</Pre>
7777
</Code.Next>
78+
<Code.Qwik>
79+
<Pre data-copy="">
80+
<NXCode>
81+
<span>{`[origin]/auth/callback/${providerId}`}</span>
82+
</NXCode>
83+
</Pre>
84+
</Code.Qwik>
7885
<Code.Svelte>
7986
<Pre data-copy="">
8087
<NXCode>
@@ -119,6 +126,20 @@ AUTH_${providerId.toUpperCase().replace(/-/gi, "_")}_SECRET={CLIENT_SECRET}
119126
}}
120127
/>
121128
</Code.Next>
129+
<Code.Qwik>
130+
<Pre
131+
data-copy=""
132+
data-filename=".env.local"
133+
dangerouslySetInnerHTML={{
134+
__html: highlight(
135+
`
136+
AUTH_${providerId.toUpperCase().replace(/-/gi, "_")}_ID={CLIENT_ID}
137+
AUTH_${providerId.toUpperCase().replace(/-/gi, "_")}_SECRET={CLIENT_SECRET}
138+
`
139+
),
140+
}}
141+
/>
142+
</Code.Qwik>
122143
<Code.Svelte>
123144
<Pre
124145
data-copy=""

docs/pages/getting-started/adapters/azure-tables.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,32 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
5858
```
5959

6060
</Code.Next>
61+
<Code.Qwik>
62+
63+
```ts filename="/src/routes/[email protected]"
64+
import { QwikAuth$ } from "@auth/qwik"
65+
import { TableStorageAdapter } from "@auth/azure-tables-adapter"
66+
import { AzureNamedKeyCredential, TableClient } from "@azure/data-tables"
67+
68+
const credential = new AzureNamedKeyCredential(
69+
import.meta.env.AUTH_AZURE_ACCOUNT,
70+
import.meta.env.AUTH_AZURE_ACCESS_KEY
71+
)
72+
const authClient = new TableClient(
73+
import.meta.env.AUTH_AZURE_TABLES_ENDPOINT,
74+
"auth",
75+
credential
76+
)
77+
78+
export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
79+
() => ({
80+
providers: [],
81+
adapter: TableStorageAdapter(authClient),
82+
})
83+
)
84+
```
85+
86+
</Code.Qwik>
6187
<Code.Svelte>
6288

6389
```ts filename="./src/auth.ts"

docs/pages/getting-started/adapters/d1.mdx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
3737
```
3838

3939
</Code.Next>
40+
<Code.Qwik>
41+
42+
```ts filename="/src/routes/[email protected]"
43+
import { QwikAuth$ } from "@auth/qwik"
44+
import { D1Adapter } from "@auth/d1-adapter"
45+
46+
export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
47+
() => ({
48+
providers: [],
49+
adapter: D1Adapter(env.db),
50+
})
51+
)
52+
```
53+
54+
</Code.Qwik>
4055
<Code.Svelte>
4156

4257
```ts filename="./src/auth.ts"

docs/pages/getting-started/adapters/dgraph.mdx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,27 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
4646
```
4747

4848
</Code.Next>
49+
<Code.Qwik>
50+
51+
```ts filename="/src/routes/[email protected]"
52+
import { QwikAuth$ } from "@auth/qwik"
53+
import { DgraphAdapter } from "@auth/dgraph-adapter"
54+
55+
export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
56+
() => ({
57+
providers: [],
58+
adapter: DgraphAdapter({
59+
endpoint: import.meta.env.DGRAPH_GRAPHQL_ENDPOINT,
60+
authToken: import.meta.env.DGRAPH_GRAPHQL_KEY,
61+
// you can omit the following properties if you are running an unsecure schema
62+
authHeader: import.meta.env.AUTH_HEADER, // default: "Authorization",
63+
jwtSecret: import.meta.env.SECRET,
64+
}),
65+
})
66+
)
67+
```
68+
69+
</Code.Qwik>
4970
<Code.Svelte>
5071

5172
```ts filename="./src/auth.ts"

docs/pages/getting-started/adapters/drizzle.mdx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,22 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
369369
```
370370

371371
</Code.Next>
372+
<Code.Qwik>
373+
374+
```ts filename="/src/routes/[email protected]"
375+
import { QwikAuth$ } from "@auth/qwik"
376+
import { DrizzleAdapter } from "@auth/drizzle-adapter"
377+
import { db } from "./schema.ts"
378+
379+
export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
380+
() => ({
381+
providers: [],
382+
adapter: DrizzleAdapter(db),
383+
})
384+
)
385+
```
386+
387+
</Code.Qwik>
372388
<Code.Svelte>
373389

374390
```ts filename="./src/auth.ts"

docs/pages/getting-started/adapters/dynamodb.mdx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,39 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
6767
```
6868

6969
</Code.Next>
70+
<Code.Qwik>
71+
72+
```ts filename="/src/routes/[email protected]"
73+
import { QwikAuth$ } from "@auth/qwik"
74+
import { DynamoDB, DynamoDBClientConfig } from "@aws-sdk/client-dynamodb"
75+
import { DynamoDBDocument } from "@aws-sdk/lib-dynamodb"
76+
import { DynamoDBAdapter } from "@auth/dynamodb-adapter"
77+
78+
const config: DynamoDBClientConfig = {
79+
credentials: {
80+
accessKeyId: import.meta.env.AUTH_DYNAMODB_ID,
81+
secretAccessKey: import.meta.env.AUTH_DYNAMODB_SECRET,
82+
},
83+
region: import.meta.env.AUTH_DYNAMODB_REGION,
84+
}
85+
86+
const client = DynamoDBDocument.from(new DynamoDB(config), {
87+
marshallOptions: {
88+
convertEmptyValues: true,
89+
removeUndefinedValues: true,
90+
convertClassInstanceToMap: true,
91+
},
92+
})
93+
94+
export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
95+
() => ({
96+
providers: [],
97+
adapter: DynamoDBAdapter(client),
98+
})
99+
)
100+
```
101+
102+
</Code.Qwik>
70103
<Code.Svelte>
71104

72105
```ts filename="./src/auth.ts"

0 commit comments

Comments
 (0)