Skip to content

Commit b9eb62d

Browse files
Sync documentation updates
1 parent 38d495f commit b9eb62d

2 files changed

Lines changed: 59 additions & 56 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { jwtExamples } from './jwt';
2+
3+
export const conceptsExamples = {
4+
'jwt': jwtExamples,
5+
};
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import { CodeExample } from '../lib/code-examples';
1+
import { CodeExample } from '../../lib/code-examples';
22

3-
export const conceptsExamples = {
4-
'jwt': {
5-
'client-side-usage': [
6-
{
7-
language: 'JavaScript',
8-
framework: 'Next.js',
9-
code: `import { useUser } from '@stackframe/stack';
3+
export const jwtExamples = {
4+
'client-side-usage': [
5+
{
6+
language: 'JavaScript',
7+
framework: 'Next.js',
8+
code: `import { useUser } from '@stackframe/stack';
109
1110
export function UserProfile() {
1211
const user = useUser();
@@ -17,13 +16,13 @@ export function UserProfile() {
1716
1817
return <div>Welcome, {user.displayName}!</div>;
1918
}`,
20-
highlightLanguage: 'tsx',
21-
filename: 'app/components/user-profile.tsx'
22-
},
23-
{
24-
language: 'JavaScript',
25-
framework: 'React',
26-
code: `import { useUser } from '@stackframe/react';
19+
highlightLanguage: 'tsx',
20+
filename: 'app/components/user-profile.tsx'
21+
},
22+
{
23+
language: 'JavaScript',
24+
framework: 'React',
25+
code: `import { useUser } from '@stackframe/react';
2726
2827
export function UserProfile() {
2928
const user = useUser();
@@ -34,16 +33,16 @@ export function UserProfile() {
3433
3534
return <div>Welcome, {user.displayName}!</div>;
3635
}`,
37-
highlightLanguage: 'tsx',
38-
filename: 'components/UserProfile.tsx'
39-
},
40-
] as CodeExample[],
36+
highlightLanguage: 'tsx',
37+
filename: 'components/UserProfile.tsx'
38+
},
39+
] as CodeExample[],
4140

42-
'server-side-usage': [
43-
{
44-
language: 'JavaScript',
45-
framework: 'Next.js',
46-
code: `import { stackServerApp } from '@/stack';
41+
'server-side-usage': [
42+
{
43+
language: 'JavaScript',
44+
framework: 'Next.js',
45+
code: `import { stackServerApp } from '@/stack';
4746
4847
export async function GET() {
4948
const user = await stackServerApp.getUser();
@@ -61,16 +60,16 @@ export async function GET() {
6160
// Other user properties...
6261
});
6362
}`,
64-
highlightLanguage: 'typescript',
65-
filename: 'app/api/user/route.ts'
66-
},
67-
] as CodeExample[],
63+
highlightLanguage: 'typescript',
64+
filename: 'app/api/user/route.ts'
65+
},
66+
] as CodeExample[],
6867

69-
'manual-jwt-verification': [
70-
{
71-
language: 'JavaScript',
72-
framework: 'Node.js',
73-
code: `import * as jose from 'jose';
68+
'manual-jwt-verification': [
69+
{
70+
language: 'JavaScript',
71+
framework: 'Node.js',
72+
code: `import * as jose from 'jose';
7473
7574
// Get the public key set from Stack Auth
7675
const jwks = jose.createRemoteJWKSet(
@@ -88,16 +87,16 @@ try {
8887
} catch (error) {
8988
console.error('JWT verification failed:', error);
9089
}`,
91-
highlightLanguage: 'typescript',
92-
filename: 'verify-jwt.ts'
93-
},
94-
] as CodeExample[],
90+
highlightLanguage: 'typescript',
91+
filename: 'verify-jwt.ts'
92+
},
93+
] as CodeExample[],
9594

96-
'manual-jwt-verification-anonymous': [
97-
{
98-
language: 'JavaScript',
99-
framework: 'Node.js',
100-
code: `import * as jose from 'jose';
95+
'manual-jwt-verification-anonymous': [
96+
{
97+
language: 'JavaScript',
98+
framework: 'Node.js',
99+
code: `import * as jose from 'jose';
101100
102101
const jwks = jose.createRemoteJWKSet(
103102
new URL('https://api.stack-auth.com/api/v1/projects/YOUR_PROJECT_ID/.well-known/jwks.json?include_anonymous=true')
@@ -110,16 +109,16 @@ const { payload } = await jose.jwtVerify(token, jwks, {
110109
],
111110
audience: ['YOUR_PROJECT_ID', 'YOUR_PROJECT_ID:anon'],
112111
});`,
113-
highlightLanguage: 'typescript',
114-
filename: 'verify-jwt.ts'
115-
},
116-
] as CodeExample[],
112+
highlightLanguage: 'typescript',
113+
filename: 'verify-jwt.ts'
114+
},
115+
] as CodeExample[],
117116

118-
'manual-jwt-verification-restricted': [
119-
{
120-
language: 'JavaScript',
121-
framework: 'Node.js',
122-
code: `import * as jose from 'jose';
117+
'manual-jwt-verification-restricted': [
118+
{
119+
language: 'JavaScript',
120+
framework: 'Node.js',
121+
code: `import * as jose from 'jose';
123122
124123
const jwks = jose.createRemoteJWKSet(
125124
new URL('https://api.stack-auth.com/api/v1/projects/YOUR_PROJECT_ID/.well-known/jwks.json?include_anonymous=true&include_restricted=true')
@@ -132,9 +131,8 @@ const { payload } = await jose.jwtVerify(token, jwks, {
132131
],
133132
audience: ['YOUR_PROJECT_ID', 'YOUR_PROJECT_ID:anon', 'YOUR_PROJECT_ID:restricted'],
134133
});`,
135-
highlightLanguage: 'typescript',
136-
filename: 'verify-jwt.ts'
137-
},
138-
] as CodeExample[],
139-
},
134+
highlightLanguage: 'typescript',
135+
filename: 'verify-jwt.ts'
136+
},
137+
] as CodeExample[],
140138
};

0 commit comments

Comments
 (0)