Overview
Context7 can retrieve documentation for specific versions of libraries. This ensures you get accurate, version-appropriate code examples and API references.Why Specify Versions?
Libraries change over time. An API that works in version 2 might not exist or work differently in version 3. Specifying versions helps you:- Get documentation matching your project’s dependencies
- Avoid breaking changes from newer versions
- Understand migration paths between versions
- Work with legacy codebases accurately
How to Specify Versions
Simply mention the version number in your prompt. Context7’s natural language processing automatically detects version references.Basic Version Syntax
Natural Language Versions
You can also use natural language to refer to versions:Version Format Examples
Context7 recognizes various version formats:Numeric versions
Numeric versions
Prefixed with 'v'
Prefixed with 'v'
In context
In context
With library ID
With library ID
Combining Versions with Library IDs
For maximum precision, combine version specification with library IDs:- Correct library (no ambiguity)
- Correct version (exact match)
- Faster response (skips library search)
Version Availability
Not all versions may be available in Context7’s index. Here’s what to expect:Latest Versions
Current and recent major versions are typically well-covered.
Older Versions
Some older versions may have limited or no documentation.
Beta/RC Versions
Pre-release versions may not be indexed.
Deprecated Versions
Very old or deprecated versions might not be available.
If a specific version isn’t available, Context7 will return the closest available version or the latest version.
Checking Your Project’s Versions
Before requesting documentation, check which versions your project uses:- Node.js/npm
- Python/pip
- Ruby/Bundler
Practical Examples
Example 1: Next.js Middleware
Example 2: React Hooks Migration
Example 3: Supabase Authentication
Version Ranges
While Context7 doesn’t support exact semver ranges, you can describe version ranges in natural language:SDK Usage with Versions
When using the Context7 SDK, include version information in your query:Troubleshooting Version Requests
Getting docs for wrong version
Getting docs for wrong version
Problem: Requested Next.js 14 docs but got Next.js 13 examples.Solutions:
- Be more explicit: “Next.js version 14” instead of “Next.js 14”
- Mention version multiple times in your prompt
- Use library ID with version:
use library /vercel/next.js v14 - Check if the specific version is indexed on context7.com
Version not available
Version not available
Problem: The version you requested doesn’t exist in Context7.Solutions:
- Check if you have the version number correct
- Try a nearby version (e.g., 14.0 instead of 14.1)
- Use the latest version if your version is very old
- Submit the library version to Context7
Unclear which version was used
Unclear which version was used
Problem: Not sure which version Context7 used in its response.Solutions:
- Ask explicitly: “Which version of Next.js are these examples from?”
- Check the documentation URLs in the response
- Look for version-specific features in code examples
Mixed version documentation
Mixed version documentation
Problem: Getting examples from multiple versions mixed together.Solutions:
- Use library ID to reduce ambiguity
- Ask for specific version in each prompt
- Add a rule that specifies your project’s versions:
Version-Specific Rules
You can add version information to your project rules:.cursorrules
Best Practices
Be specific
Include version numbers in prompts when it matters:
- Migration questions
- Breaking change concerns
- Legacy codebase work
Use latest for new projects
For greenfield projects, you can usually omit version numbers to get the latest docs.
Next Steps
Best Practices
Learn more ways to optimize your Context7 usage.
Adding Libraries
Submit a library or version to Context7.