Next.js SDK
Last updated: Oct-26-2026
The Cloudinary Next.js SDK provides simple, yet comprehensive image and video rendering, transformation, optimization, and delivery capabilities that you can implement using code that integrates seamlessly with your existing Next.js application.
How would you like to learn?
| Resource | Description |
|---|---|
| Next.js Starter Kit | A ready-to-use, fully functional Next.js app integrating Cloudinary upload and delivery features. Ideal for new projects and fast prototyping with AI assistance. |
| Next.js quick start | Get up and running in five minutes with a walk through of installation, configuration, upload, rendering, and transformations. |
| Video tutorials | Watch tutorials relevant to your use cases, from getting started with the Next.js SDK, to rendering and transforming your images and videos. |
| Sample projects | Explore sample projects to see how to implement Cloudinary functionality such as rendering and delivery with transformations. |
| Next Cloudinary GitHub repo | Explore the source code and see the CHANGELOG for details on all new features and fixes from previous versions. This guide documents next-cloudinary version 7.x. |
Install
Install the next-cloudinary package using the NPM package manager:
npm install next-cloudinary@6. If you're upgrading from version 6, see Upgrade from version 6 to version 7.To avoid unexpected changes in production, consider installing a specific version rather than the latest, for example npm install --save-exact next-cloudinary@7.0.0. Without --save-exact, npm saves a version range such as ^7.0.0 in your package.json.
Configure
Set required configuration parameters
Add your Cloudinary cloud name to your environment variables:
Set additional configuration parameters
In addition to the required configuration parameters, you can define a number of optional environment variables if relevant:
- You need to set the API key and secret if using the Cloudinary Upload Widget for signed uploads.
- You can share the API key publicly, but you must keep the API secret private and use it only on the server.
- For more information about the secure distribution and private CDN options, see Configuration parameters.
Configuration video tutorials
The following tutorials can help you install and set up your SDK:
See more Next.js video tutorials.
Use
Once you've installed and configured the Next.js SDK, you can use it for:
-
Rendering and transforming images - Render your images with transformations applied, using the
CldImagecomponent. See examples -
Rendering and transforming videos - Render your videos with transformations applied, using the
CldVideoPlayercomponent. See example - Uploading assets - Use the upload components to easily add upload functionality to your application. See example
-
Generating social media cards - Create Open Graph images and social media cards with the
CldOgImagecomponent. See example
Quick examples: Image transformations
Here are two quick examples to get you started with image transformations:
- Image transformation example 1 - Apply a sepia effect to an image
- Image transformation example 2 - Apply multiple transformations
A key benefit of the Next.js SDK is that it automatically optimizes images for responsiveness, format and quality. In the examples below, you'll notice c_limit, f_auto and q_auto automatically added to the generated URLs.
-
c_limit: Scales the image down to fit within the size you specify, but never scales it up. The Next.js SDK also generates multiple sizes of each image for responsive delivery, as described in the examples below. Learn more -
f_auto: Delivers the image in the best format for the requesting browser. Learn more -
q_auto: Compresses the image enough to reduce its size without impacting visual quality. Learn more
Image transformation example 1
The following Next.js code renders the front_face.jpg image with a sepia effect applied:
The width and height props should match the actual dimensions of the image (here, 292x282 pixels). This code creates the HTML required to render the following transformation URL:
The component actually renders two URLs in a srcset, one for standard screens and one for high-density (2x) screens, so that browsers can pick the size that suits the device:
c_limit, f_auto, and q_auto, are automatically applied by the Next.js SDK to each URL, and the srcset provides automatic responsive delivery.Image transformation example 2
You can apply more than one transformation at a time to give more interesting results:
This code performs all of the following on the original front_face.jpg image before delivering it:
- Crop to a 150x150 thumbnail using face-detection gravity to automatically determine the location for the crop
- Round the corners with a 20 pixel radius
- Apply a sepia effect
- Overlay the Cloudinary logo on the southeast corner of the image (with a slight offset). Scale the logo overlay down to a 50 pixel width, with increased brightness and partial transparency (opacity = 60%).
- Rotate the resulting image (including the overlay) by 10 degrees
And here's the URL that's automatically generated and rendered from the above code:
c_limit,w_384/f_auto/q_auto, are automatically applied by the Next.js SDK.- Read the image transformation guide to learn about the different ways to transform your images.
- See more examples of image transformations using the Cloudinary Next.js SDK.
- See all possible transformations in the Transformation URL API reference.
Quick example: Video transformations
Here's an example to get you started with video transformations using the CldVideoPlayer component.
The following Next.js code renders the ship.mp4 video with the Cloudinary Video Player and transformations applied:
This code performs the following transformations on the video:
- Crop to a 1:1 aspect ratio (square) with a width of 300 pixels, using automatic gravity to determine the focal point
- Apply a blur effect with strength 50
- Apply maximum rounding to create a circular video
- See the Next.js video transformations guide for all available props and examples.
- See all possible transformations in the Transformation URL API reference.
Uploading assets
The Next.js SDK provides two components for uploading assets, CldUploadButton and CldUploadWidget.
CldUploadButton
A drop-in button component that opens the Cloudinary Upload Widget:
CldUploadWidget
A customizable upload widget component:
- See the Next.js image and video upload guide for all available props and examples, including information on signed uploads for secure uploading.
Social media cards
Generate Open Graph images and social media cards with the CldOgImage component:
CldOgImage works only in the Pages Router. It doesn't work in the App Router, which the other examples in this guide assume.The component automatically generates the appropriate meta tags for social media platforms with links to the Cloudinary-hosted images.
- See the Social media cards with CldOgImage section in the image transformations guide for detailed examples and configuration options.
- Learn about Open Graph protocol for social media sharing.
Helper methods
In addition to components, the Next.js SDK provides helper methods for generating Cloudinary URLs:
getCldImageUrl
Generate a Cloudinary image URL using the same API as CldImage:
getCldOgImageUrl
Generate a Cloudinary URL specifically for OG Images or Social Media Cards:
getCldVideoUrl
Generate a Cloudinary video URL:
Next.js App Router
The Next.js SDK fully supports the App Router introduced in Next.js 13. In version 7, the Cloudinary components include the 'use client' directive, so you can use them directly in Server Components. If you pass event handlers or a render function to a component, or use hooks or other client-only code in the same file, add 'use client' at the top of that file. In version 6, add 'use client' at the top of every file that uses Cloudinary components. The following example is a Server Component, so it doesn't need the directive in version 7:
Upgrade from version 6 to version 7
Version 7 uses Cloudinary Video Player v4 in CldVideoPlayer, and updates the supported versions of Next.js, React, and Node.js. Many projects can upgrade without code changes, but check the following before you switch:
- Requirements: Your project must use Next.js 16 or later, React 18.2 or 19, and Node.js 22 or later.
-
Upload callbacks: The deprecated
onUploadcallback is removed fromCldUploadWidgetandCldUploadButton. UseonSuccessinstead. Its second argument is now an options object:
-
Video player styling:
CldVideoPlayernow uses Cloudinary Video Player v4.1.2 (previously v1.11.1). If you customize the player with your own CSS, check that it still applies. If you importnext-cloudinary/dist/cld-video-player.css, it updates automatically. -
Package imports: Import only from
next-cloudinaryandnext-cloudinary/dist/cld-video-player.css. Other internal paths, such asnext-cloudinary/dist/index.js, no longer resolve. -
TypeScript types: The
overlayoption is removed (useoverlays),assetTypeaccepts only'image','images','video','videos', or'all', and theanalyticsargument ofgetCldImageUrlandgetCldVideoUrlno longer acceptsfalse. If you import option types directly from@cloudinary-util/url-loader, some names and shapes have changed. -
Known limitation: When you set
aspectRatioonCldVideoPlayer, the poster image doesn't load, although the video plays normally. As a workaround, also setcropMode="fill", which crops the video to that ratio.cropModeisn't in the TypeScript types yet, so in TypeScript projects pass it with a cast, for example{...({ cropMode: 'fill' } as object)}. A fix is planned for a follow-up release.
By upgrading, you also get:
- Custom posters saved in the Video Player Studio are shown automatically in
CldVideoPlayer. -
'use client'is built intoCldImage,CldUploadButton,CldUploadWidget, andCldVideoPlayer, so you can use them directly in App Router Server Components. If you pass event handlers or a render function to a component, use it in a Client Component. - A
seedoption forfillBackground. - More complete TypeScript types, such as
hueandnoise. - Fixes for
CldVideoPlayerre-initializing after navigating away and back, repeatedq_autoin video URLs, and overlay text that contains commas.
Sample projects
Take a look at the Next.js sample projects page to help you get started integrating Cloudinary into your Next.js application.
- Try out the Next.js SDK using the quick start.
- See examples of powerful image and video transformations using Next.js code, and see our image transformation and video transformation docs.
- For information about uploading images and videos from a Next.js application, see Next.js image and video upload.
- Explore the GitHub repository, Changelog, and NPM package.
- Stay tuned for updates by following the Release Notes and the Cloudinary Blog.