Welcome to your new app
Sign up for an account to get started
API request example
Response
// Click above to run the requestpages/api/getAuthenticatedUserId.js
import { withSession } from '@clerk/nextjs/api'
export default withSession((req, res) => {
res.statusCode = 200
if (req.session) {
res.json({ id: req.session.userId })
} else {
res.json({ id: null })
}
})