Unverified Commit d47f3929 authored by James Perkins's avatar James Perkins Committed by GitHub

Updating to latest version of Clerk (#41192)

## Documentation / Examples

Updating Clerk to latest example for our with-clerk. 
Co-authored-by: 's avatarjamesp-codes <84922519+jamesp-codes@users.noreply.github.com>
Co-authored-by: 's avatarBalázs Orbán <18369201+balazsorban44@users.noreply.github.com>
parent cbda3b52
NEXT_PUBLIC_CLERK_FRONTEND_API=your-frontend-api NEXT_PUBLIC_CLERK_FRONTEND_API=your_clerk_frontend_api
CLERK_API_KEY=your-api-key CLERK_API_KEY=your_clerk_api_key
\ No newline at end of file CLERK_JWT_KEY=your_clerk_jwt_key
\ No newline at end of file
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,9 +6,9 @@ ...@@ -6,9 +6,9 @@
"start": "next start" "start": "next start"
}, },
"dependencies": { "dependencies": {
"@clerk/nextjs": "1.0.1", "@clerk/nextjs": "4.5.1",
"next": "latest", "next": "latest",
"react": "17.0.2", "react": "18.2.0",
"react-dom": "17.0.2" "react-dom": "18.2.0"
} }
} }
import { withSession } from '@clerk/nextjs/api' import { getAuth } from '@clerk/nextjs/server'
export default withSession((req, res) => { export default function handler(req, res) {
res.statusCode = 200 const { sessionId, userId } = getAuth(req)
if (req.session) { if (!sessionId) {
res.json({ id: req.session.userId }) return res.status(401).json({ id: null })
} else {
res.json({ id: null })
} }
}) return res.status(200).json({ id: userId })
}
...@@ -40,16 +40,15 @@ const SignupLink = () => ( ...@@ -40,16 +40,15 @@ const SignupLink = () => (
</Link> </Link>
) )
const apiSample = `import { withSession } from '@clerk/nextjs/api' const apiSample = `import { getAuth } from '@clerk/nextjs/server'
export default withSession((req, res) => { export default function handler(req, res) {
res.statusCode = 200 const { sessionId, userId } = getAuth(req);
if (req.session) { if (!sessionId) {
res.json({ id: req.session.userId }) return res.status(401).json({ id: null });
} else {
res.json({ id: null })
} }
})` return res.status(200).json({ id: userId });
}`
// Main component using <SignedIn> & <SignedOut>. // Main component using <SignedIn> & <SignedOut>.
// //
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment