> ## Documentation Index
> Fetch the complete documentation index at: https://cloudinary.com/documentation/llms.txt
> Use this file to discover all available pages before exploring further.

# Getting started with Cloudinary in Node.js (video tutorial)

[githublink]: https://github.com/cloudinary-community/cloudinary-examples/tree/main/examples/node-image-upload

## Overview

Learn to get started with Cloudinary in a Node.js app. This tutorial covers setting up, configuring, and optimizing images using the Cloudinary Node.js SDK.

## Video tutorial

  This video is brought to you by Cloudinary's video player - embed your own!Use the controls to set the playback speed, navigate to chapters of interest and select subtitles in your preferred language.

> **TIP**: :title=View the code

You can find the code from this tutorial in [GitHub][githublink].
## Tutorial contents
This tutorial presents the following topics. Click a timestamp to jump to that part of the video.
### Introduction to Cloudinary
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=0 :sec=00 :player=cld} | Discover the power of Cloudinary, a platform for image and video management that goes beyond simple uploads. Learn about features like background removal, dynamic cropping, resizing, and AI-driven content analysis in a Node.js app.
|

### Set up Cloudinary
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=0 :sec=24 :player=cld} | Install the Cloudinary Node.js SDK using your preferred package manager e.g., `npm install cloudinary`.Import Cloudinary using `const cloudinary = require('cloudinary').v2`.Configure your account using `cloudinary.config()`, where you’ll input your `cloud_name`, `api_key`, and `api_secret`. [Learn how to find these credentials](finding_your_credentials_tutorial) in your Cloudinary dashboard.
|

### Deliver an image from Cloudinary
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=1 :sec=40 :player=cld} | You can look for an image to deliver in your Media Library.  There are some pre-uploaded ones or you can upload your own. Copy the public ID of the image to use in your script. Use the `cloudinary.url()` method to generate the delivery URL from the public ID.
|

### Transform an image
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=2 :sec=30 :player=cld} | To transform an image, add a second argument, `transformation`, to the `url` method, specifying different transformations. For example, `fetch_format: 'auto'` delivers the best format based on the browser, `quality: 'auto'` compresses the image as much as possible without visual impact, and `width:1200` resizes the image on the server side, reducing the number of bytes to deliver.
|

```nodejs
const url cloudinary.url('sample', {
  transformation: [
    {
      fetch_format: 'auto'
    },
    {
      quality: 'auto'
    },
    {
      width: 1200
    }
  ]
})
```

### Upload an image programmatically
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=4 :sec=16 :player=cld} | To upload an image programmatically, you need to configure your API key and secret. Use environment variables to store these, as you shouldn't expose your API secret to anyone.  Then you can use the `cloudinary.uploader.upload()` method to upload an image.  For example, uploading a local image:
|

```nodejs
(async function() {
  const results = await cloudinary.uploader.upload('./images/my_image.jpg');
  console.log(results);
})();
```

### Transform the uploaded image
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=7 :sec=08 :player=cld} | In the same function, use the `cloudinary.url()` method as before, but with `results.public_id` instead of the hard coded public ID. For example:
|

```nodejs
(async function() {
  const results = await cloudinary.uploader.upload('./images/my_image.jpg');
  console.log(results);
  const url = cloudinary.url(results.public_id, {
    transformation: [
      {
        quality: 'auto',
        fetch_format: 'auto'
      },
      { 
        width: 1200,
        height: 1200,
        crop: 'fill',
        gravity: 'auto'
      }
    ]
  });
  console.log(url);
})
```

Take a look at these code examples:

* [Applying transformations in Node.js](https://github.com/cloudinary-community/cloudinary-examples/tree/main/examples/node-transformations-effects)
* [Uploading images in Node.js](https://github.com/cloudinary-community/cloudinary-examples/tree/main/examples/node-image-upload)

## Keep learning

> **READING**:
>
> * Take a look at our [Node.js SDK](node_integration) to learn how to [upload](node_image_and_video_upload) and transform your [images](node_image_manipulation) and [videos](node_video_manipulation).

> * Watch more [Dev Hints videos](https://www.youtube.com/playlist?list=PL8dVGjLA2oMpaTbvoKCaRNBMQzBUIv7N8) on the [Cloudinary YouTube channel](https://www.youtube.com/cloudinary).

#### If you like this, you might also like...

  
  
  
    Configure the Node.js SDK
    Install and configure the Cloudinary Node.js SDK 
  

  
  
  
    Captioning on Upload with Node.js
    Save auto-generated captions to use as alt text with Node.js 
  

  
  
  
    Delete Assets with Node.js
    Delete assets using various methods from the Node.js SDK 
  

&nbsp;

&nbsp;Check out the Cloudinary Academy for free self-paced Cloudinary courses on a variety of developer or DAM topics, or register for formal instructor-led courses, either virtual or on-site.
&nbsp;
