Image & Video APIs

Next.js quick start

Last updated: Feb-26-2026

This quick start lets you get an end-to-end implementation up and running using the Next.js SDK in 5 minutes or less.

1. Set up and configure the SDK

Install the package

Install the required package using the NPM package manager:

Tip
The next-cloudinary package provides all the components and helpers you need to work with Cloudinary in Next.js.

Configure Cloudinary

Create or update your .env.local file in your Next.js project root and add your cloud name:

.env.local

2. Upload an image

The Next.js SDK provides easy-to-use upload components. For this quick start, we'll use the CldUploadButton component to upload an image.

First, you need to create an upload preset in your Cloudinary Console:

  1. Log into your Cloudinary Console
  2. Go to Settings > Upload
  3. Scroll to Upload presets and click Add upload preset
  4. Set Signing Mode to Unsigned
  5. Set Folder to docs (optional, but helps organize your assets)
  6. Click Save
  7. Copy the Preset name - you'll need this in the next step

Now add upload functionality to your project (if you've created a new Next.js project, you can replace the contents of app/page.tsx, otherwise create a new page in your project, or modify an existing page):

app/page.tsx

Replace your_upload_preset with the preset name you copied from the Cloudinary Console.

This code creates an "Upload Image" button, which, when clicked, opens the Cloudinary Upload Widget, allowing you to upload from various sources.

Tip
For production applications, you should use signed uploads for better security. Learn more in the Next.js image and video upload guide.

3. Transform and deliver the image

Following upload, you can use the CldImage component to transform and deliver the image, using its public ID.

Update your page to include the transformation:

  1. Add CldImage to the import from next-cloudinary.

  2. Add the CldImage component inside the conditional block, after the Public ID paragraph and before the closing </div>:

    The CldImage component uses the uploaded image's public ID to apply transformations:

    • width: 250 pixels
    • height: 250 pixels
    • crop: fill (ensures the image fills the entire space)

The full code should look like this (with your_upload_preset replaced with your own upload preset name):

app/page.tsx

Note
When using the App Router in Next.js 13+, add the 'use client' directive at the top of your file to use Cloudinary components.

4. Run your code

Start your Next.js development server:

Navigate to http://localhost:3000 (or your configured port) and:

  1. Click the "Upload Image" button
  2. Upload an image using the Cloudinary Upload Widget
  3. After upload completes, you'll see:
    • The public ID
    • The transformed image (250x250, cropped to fill)

Transformed models image

View the completed code

You can find the full code example for this quick start on GitHub.

Ready to learn more?

✔️ Feedback sent!

Rate this page:

one star two stars three stars four stars five stars