Skip to main content

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
Without version specification, Context7 typically returns documentation for the latest stable version.

How to Specify Versions

Simply mention the version number in your prompt. Context7’s natural language processing automatically detects version references.

Basic Version Syntax

Context7 automatically matches the appropriate version documentation.

Natural Language Versions

You can also use natural language to refer to versions:

Version Format Examples

Context7 recognizes various version formats:

Combining Versions with Library IDs

For maximum precision, combine version specification with library IDs:
This ensures:
  • 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:

Practical Examples

Example 1: Next.js Middleware

1

Check your Next.js version

2

Request version-specific docs

3

Get accurate results

Context7 returns middleware examples specific to Next.js 14’s App Router, not the older Pages Router.

Example 2: React Hooks Migration

This helps you understand what changed between versions.

Example 3: Supabase Authentication

Ensures you get v2 authentication patterns, not v1.

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

Problem: Requested Next.js 14 docs but got Next.js 13 examples.Solutions:
  1. Be more explicit: “Next.js version 14” instead of “Next.js 14”
  2. Mention version multiple times in your prompt
  3. Use library ID with version: use library /vercel/next.js v14
  4. Check if the specific version is indexed on context7.com
Problem: The version you requested doesn’t exist in Context7.Solutions:
  1. Check if you have the version number correct
  2. Try a nearby version (e.g., 14.0 instead of 14.1)
  3. Use the latest version if your version is very old
  4. Submit the library version to Context7
Problem: Not sure which version Context7 used in its response.Solutions:
  1. Ask explicitly: “Which version of Next.js are these examples from?”
  2. Check the documentation URLs in the response
  3. Look for version-specific features in code examples
Problem: Getting examples from multiple versions mixed together.Solutions:
  1. Use library ID to reduce ambiguity
  2. Ask for specific version in each prompt
  3. Add a rule that specifies your project’s versions:

Version-Specific Rules

You can add version information to your project rules:
.cursorrules
This ensures consistency across all Context7 invocations.

Best Practices

1

Know your versions

Keep track of the library versions your project uses.
2

Be specific

Include version numbers in prompts when it matters:
  • Migration questions
  • Breaking change concerns
  • Legacy codebase work
3

Use latest for new projects

For greenfield projects, you can usually omit version numbers to get the latest docs.
4

Document in rules

Add your project’s versions to your rules file for consistency.

Next Steps

Best Practices

Learn more ways to optimize your Context7 usage.

Adding Libraries

Submit a library or version to Context7.