Learn: General
November 7, 2025

Framework vs SDK vs Library: What is the difference?

Cover Image

You've used "framework," "SDK," and "library" in code reviews and architecture discussions. But here's the thing: most developers use these terms interchangeably, and that creates real confusion when you're trying to make informed technical decisions.

The distinctions aren't just semantic. They're architectural.

The Control Flow Principle

Here's what separates these tools: who's in control of your application's execution flow.

Libraries: You call the code when you need it. You control when and how the code executes.

Frameworks: The code calls you at predetermined points. The framework controls the execution flow, and your code responds to it.

SDKs: Complete development kits that package everything you need: libraries, tools, docs, and sample code for building on a specific platform or service.

This isn't about size or popularity. It's about inversion of control: a fundamental architectural principle that determines how your code is structured and executed.

Libraries: Your Tools, Your Control

A library is a collection of reusable functions, classes, or modules that you call directly. You maintain complete architectural control over when and how to invoke library functions.

Look at lodash. You import what you need (import { debounce } from 'lodash') and call it when you want:

// You decide when and how to use lodash const debouncedSave = debounce(saveUserData, 300); debouncedSave(userData); // You call the library function

Lodash doesn't dictate your application structure, manage rendering, or control execution flow. It's purely functional: you call it, it returns a result, done.

The same principle applies to axios for HTTP requests or date-fns for date manipulation. These libraries provide focused functionality that you invoke on-demand without architectural constraints.

Key characteristic: Normal call flow where your application code calls library functions.

Frameworks: The Architectural Skeleton

A framework provides the structural foundation of your application and controls the execution flow. You write code that the framework calls at predetermined extension points.

Next.js exemplifies this perfectly. When you build a Next.js page, the framework controls when server-side rendering happens and when client-side hydration kicks in:

// pages/users/[id].js export default function UserProfile({ user }) { return <div>{user.name}</div> } // Next.js framework calls this method during its rendering lifecycle export async function getServerSideProps(context) { const { id } = context.params const user = await fetchUser(id) return { props: { user } } }

Next.js controls the rendering lifecycle, routing, and data fetching patterns. You write code that fits into Next.js's patterns, and the framework determines when and how your code executes.

Django demonstrates this same principle in the Python backend world. You write views and models following Django's conventions, but Django controls the request/response cycle through its URL patterns and middleware:

# models.py class Article(models.Model): title = models.CharField(max_length=200) content = models.TextField() # views.py def article_detail(request, article_id): # Django framework calls this function based on URL pattern matching article = get_object_or_404(Article, pk=article_id) return render(request, 'articles/detail.html', {'article': article})

Rails operates similarly in the Ruby ecosystem. You write controllers and models following Rails conventions, but Rails controls the request/response cycle through its routing system and middleware pipeline, calling your code at predetermined points.

class ArticlesController < ApplicationController # Rails framework calls this method based on routing def show @article = Article.find(params[:id]) # Rails framework determines when this executes through inversion of control end end

Key characteristic: Inversion of control where the framework calls your code at specific lifecycle points.

SDKs: Comprehensive Development Kits

An SDK packages everything you need to develop for a specific platform: libraries, tools, documentation, sample code, and platform-specific utilities.

The AWS SDK illustrates this comprehensively. It's a complete development kit that goes far beyond simple API wrappers:

import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; const client = new S3Client({ region: "us-west-2" }); // SDK handles authentication, retries, error handling, request signing await client.send(new PutObjectCommand({ Bucket: "my-bucket", Key: "file.jpg", Body: fileBuffer }));

The AWS SDK handles authentication, error handling, retries, pagination: complexity you'd otherwise implement manually. You could interact with AWS APIs directly using raw HTTP requests, but the SDK bundles the complete toolkit for efficient AWS integration.

Key characteristic: Comprehensive development kit bundling libraries, tools, documentation, and platform-specific utilities.

Real-World Examples You Use Every Day

Here's a quick reference of common tools you encounter:

Frameworks:

  • React: Actually a library despite common misconceptions: you call React components when you need them, React doesn't control your application architecture
  • Next.js: React framework that controls routing, rendering, and data fetching patterns
  • Vue: Progressive framework with reactivity system and lifecycle hooks
  • Express.js: Minimal backend framework providing routing middleware and request/response handling
  • Django: "Batteries included" Python framework with MTV architecture and built-in ORM
  • Ruby on Rails: Highly opinionated framework enforcing MVC patterns and "convention over configuration"

SDKs:

  • Stripe SDK: Complete payment processing kit with PCI compliance and webhook handling
  • Firebase SDK: Backend-as-a-Service with authentication, real-time database, and deployment tools
  • Twilio SDK: Communications platform with SMS, voice, video, and webhook verification
  • AWS SDK: Comprehensive cloud services integration with 200+ service clients

Libraries:

  • lodash: Utility functions for data manipulation
  • axios: HTTP client with interceptors and error handling
  • D3.js: Data visualization with SVG/Canvas binding
  • jQuery: DOM manipulation and cross-browser compatibility

The Misconceptions That Trip Up Developers

React is a library, not a framework

React explicitly describes itself as "a JavaScript library for building user interfaces." The confusion arises because React's ecosystem: React Router, Redux, Next.js provides framework-like capabilities when combined. But React itself leaves routing, data fetching, and application architecture decisions to you.

SDKs and APIs are different concepts

An API is an interface specification: the contract defining how components communicate. An SDK is a complete development package that includes APIs plus tools, documentation, debuggers, and sample code. You can consume any API directly using curl or fetch. The SDK makes it easier by handling authentication, error handling, and providing language-specific abstractions.

Size doesn't determine the category

A massive utility library like lodash remains a library because you call its functions. A minimal framework like Express.js is still a framework because it controls the HTTP request/response cycle and calls your route handlers.

Making the Right Choice for Your Project

Choose frameworks when:

  • Building standard applications with established patterns
  • Your team needs architectural guidance and conventions
  • Development speed outweighs flexibility requirements

Choose libraries when:

  • You need fine-grained architectural control
  • Building specialized or performance-critical components
  • Maximum flexibility with minimal constraints is essential

Choose SDKs when:

  • Integrating with external platforms or services
  • Platform-specific optimizations are required
  • Your team lacks deep expertise in platform-specific details

The Practical Reality

Real-world applications typically combine all three approaches. You might use React (library) for UI components, Next.js (framework) for application structure and routing, and the Stripe SDK for payment processing. The key is making deliberate choices based on technical requirements and architectural trade-offs rather than popularity or personal preferences.

Understanding these distinctions enables clearer architectural discussions, more informed technical decisions, and better communication with your team. When someone suggests "using the React framework," you'll know to clarify whether they mean React the library, a React-based framework like Next.js, or the broader React ecosystem.

The choice between control and convenience is yours to make. But now you know exactly what you're choosing between.