Install the Package
Add Sanity Image to your project using your preferred package manager:Requirements
Sanity Image has minimal requirements to keep your bundle size small:Peer Dependencies
You need React 18 or higher installed in your project:Sanity Image has zero dependencies beyond React. The entire package is just 4kb (2kb gzipped).
TypeScript Support
Sanity Image includes full TypeScript definitions out of the box. No additional@types packages are needed.
If you’re using TypeScript, the component provides:
- Full type safety for all props
- Polymorphic component types (when using the
asprop) - Exported utility types like
WrapperPropsfor creating wrapper components - Type definitions for all utility functions
Framework Compatibility
Sanity Image works with any React-based framework:- Next.js — Works in both App Router and Pages Router
- Gatsby — Full compatibility with Gatsby’s build process
- Remix — Works in both client and server components
- Create React App — Drop-in compatibility
- Vite — Full support for Vite-based projects
- Any React framework — If it runs React, it works
The package is marked as having no side effects (
"sideEffects": false), which enables optimal tree-shaking in modern bundlers.Verify Installation
Confirm the package is installed correctly:Next Steps
Quick Start Guide
Learn how to render your first optimized image with Sanity Image