Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating to latest version of Clerk #41192

Merged
merged 4 commits into from Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions examples/with-clerk/.env.local.example
@@ -1,2 +1,3 @@
NEXT_PUBLIC_CLERK_FRONTEND_API=your-frontend-api
CLERK_API_KEY=your-api-key
NEXT_PUBLIC_CLERK_FRONTEND_API=your_clerk_frontend_api
CLERK_API_KEY=your_clerk_api_key
CLERK_JWT_KEY=your_clerk_jwt_key
10 changes: 10 additions & 0 deletions examples/with-clerk/middleware.js
@@ -0,0 +1,10 @@
import { withClerkMiddleware } from '@clerk/nextjs/server'
import { NextResponse } from 'next/server'

export default withClerkMiddleware((_req) => {
return NextResponse.next()
})

export const config = {
matcher: ['/api/getAuthenticatedUserId'],
}
6 changes: 3 additions & 3 deletions examples/with-clerk/package.json
Expand Up @@ -6,9 +6,9 @@
"start": "next start"
},
"dependencies": {
"@clerk/nextjs": "1.0.1",
"@clerk/nextjs": "4.5.1",
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2"
"react": "18.2.0",
"react-dom": "18.2.0"
}
}
15 changes: 7 additions & 8 deletions examples/with-clerk/pages/api/getAuthenticatedUserId.js
@@ -1,10 +1,9 @@
import { withSession } from '@clerk/nextjs/api'
import { getAuth } from '@clerk/nextjs/server'

export default withSession((req, res) => {
res.statusCode = 200
if (req.session) {
res.json({ id: req.session.userId })
} else {
res.json({ id: null })
export default function handler(req, res) {
const { sessionId, userId } = getAuth(req)
if (!sessionId) {
return res.status(401).json({ id: null })
}
})
return res.status(200).json({ id: userId })
}
15 changes: 7 additions & 8 deletions examples/with-clerk/pages/index.js
Expand Up @@ -40,16 +40,15 @@ const SignupLink = () => (
</Link>
)

const apiSample = `import { withSession } from '@clerk/nextjs/api'
const apiSample = `import { getAuth } from '@clerk/nextjs/server'
export default withSession((req, res) => {
res.statusCode = 200
if (req.session) {
res.json({ id: req.session.userId })
} else {
res.json({ id: null })
export default function handler(req, res) {
const { sessionId, userId } = getAuth(req);
if (!sessionId) {
return res.status(401).json({ id: null });
}
})`
return res.status(200).json({ id: userId });
}`

// Main component using <SignedIn> & <SignedOut>.
//
Expand Down