Get documentation context
curl --request GET \
--url https://context7.com/api/v2/context \
--header 'Authorization: Bearer <token>'
{
"codeSnippets": [
{
"codeTitle": "Middleware Authentication Example",
"codeDescription": "Shows how to implement authentication checks in Next.js middleware",
"codeLanguage": "typescript",
"codeTokens": 150,
"codeId": "https://github.com/vercel/next.js/blob/canary/docs/middleware.mdx#_snippet_0",
"pageTitle": "Middleware",
"codeList": [
{
"language": "typescript",
"code": "import { NextResponse } from 'next/server'\nimport type { NextRequest } from 'next/server'\n\nexport function middleware(request: NextRequest) {\n const token = request.cookies.get('token')\n if (!token) {\n return NextResponse.redirect(new URL('/login', request.url))\n }\n return NextResponse.next()\n}"
}
]
}
],
"infoSnippets": [
{
"pageId": "https://github.com/vercel/next.js/blob/canary/docs/middleware.mdx",
"breadcrumb": "Routing > Middleware",
"content": "Middleware allows you to run code before a request is completed...",
"contentTokens": 200
}
]
}