---
title: "Stack"
description: "Stack"
url: "https://www.contentstack.com/docs/developers/sdks/content-delivery-sdk/javascript-browser/reference/stack"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-09-20"
---

# Stack

## Stack

Initialize an instance of ‘Stack’

## setProtocol

Sets the protocol for the host

```
import Contentstack from 'contentstack'

const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});
Stack.setProtocol('https');
```

Web Protocol for request (http or https)

## setHost

Sets the host of the API server

```
import Contentstack from 'contentstack'

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
Stack.setHost('custom.contentstack.com');
```

Sets the host of the API server

## setPort

Sets the port of the host

```
import Contentstack from 'contentstack'
const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
Stack.setPort(443);
```

Port number of the endpoint

## setCachePolicy

Allows you to set cache policies

```
import Contentstack from 'contentstack'

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
Stack.setCachePolicy(Contentstack.CachePolicy.IGNORE_CACHE);
```

## setCacheProvider

Sets the Cache Provider's get and set methods used in SDK to cache data.

```
import Contentstack from 'contentstack';

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
Stack.setCacheProvider({
  get: function (key, callback) {
    try {
        callback(null, <cache_provider>.get(key));
    } catch(e) {
        callback(e);
    }
  },
  set: function (key, value, callback) {
    try {
        if(key && value) <cache_provider>.set(key, value);
        callback();
    } catch(e) {
        callback(e);
    }
  }
});
```

## getCacheProvider

Returns the currently set object of 'CacheProvider'

```
import Contentstack from 'contentstack'

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
Stack.getCacheProvider();
```

## Assets

Retrieves all assets of a stack by default. To retrieve a single asset, specify its UID.

```
To get all Assets from the stack:
import Contentstack from 'contentstack'

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
const result = await Stack.Assets().Query().toJSON().find();
To get a specific Asset from the stack using UID:
import Contentstack from 'contentstack'

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
const result = await Stack.Assets('asset_uid').toJSON().find();
```

UID of the asset

## ContentType

Set the content type of which you want to retrieve the entries

```
import Contentstack from 'contentstack'

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
const result = await Stack.ContentType('content_type_uid').Query().toJSON().find();
```

UID of the existing content type

## getContentTypes

This method returns comprehensive information of all the content types of a particular stack in your account.

```
import Contentstack from 'contentstack'

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
Const result = await Stack.getContentTypes({"include_global_field_schema": true});
```

## getLastActivities

The getLastActivities retrieves all the ContentTypes whose last activity updated.

```
import Contentstack from 'contentstack';

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
const result = await Stack.getLastActivities().toJSON().fetch();
```

## Taxonomies

Set the base URL to the taxonomies endpoint.

```
Example:
import Contentstack from 'contentstack';
const stack = Contentstack.stack('api_key', 'delivery_token', 'environment');

let data;
stack
.Taxonomies()
.where("taxonomies.taxonomy_uid", "term_uid")
.toJSON()
.find()
.then(response => {
  // the response
  data = response;
})
```

## Query

An initializer is responsible for creating Query object.Provides support for all search queries

```
import Contentstack from 'contentstack';

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
const result = await Stack.ContentType('content_type_uid').Query().toJSON().find();
import Contentstack from 'contentstack';

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
const result = await Stack.Assets().Query().toJSON().find();
```

## imageTransform

Performs transformations on images of mentioned url based on transformation parameters

```
import Contentstack from 'contentstack'

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
Stack.imageTransform(imageURL, {height: 100, width: 200, disable: "upscale"});import Contentstack from 'contentstack'

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
Stack.imageTransform(imageURL, {crop: "150,100"});import Contentstack from 'contentstack'

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
Stack.imageTransform(imageURL, {format: "png", crop: "150,100"});
```

Image url on which transformations need to be applied.

Object with transformation parameters

## sync

Syncs your Contentstack data with your app and ensures that the data is always up-to-date by providing delta updates

```
For initializing sync:
import Contentstack from 'contentstack'

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
const result = await Stack.sync({'init': true});
For initializing sync with entries of a specific locale:
import Contentstack from 'contentstack'

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
const result = await Stack.sync({'init': true, 'locale': 'en-us'});

For initializing sync with entries published after a specific date:
import Contentstack from 'contentstack'

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
const result = await Stack.sync({'init': true, 'start_date': '2018-10-22'});

For initializing sync with entries of a specific content type:
import Contentstack from 'contentstack'

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
const result = await Stack.sync({'init': true, 'content_type_uid': 'session'});

For initializing sync with specific type:
import Contentstack from 'contentstack'

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
const result = await Stack.sync({'init': true, 'type': 'entry_published'});

For fetching the next batch of entries using pagination token:
import Contentstack from 'contentstack'

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
const result = await Stack.sync({'pagination_token': '<page_token>'});

For performing subsequent sync after initial sync:
import Contentstack from 'contentstack'

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});
const result = await Stack.sync({'sync_token': '<sync_token>'})
```

initializing sync

initializing sync with entries of a specific locale

initializing sync with entries of a specific content type

Use the type parameter to get a specific type of content.Supports 'asset\_published', 'entry\_published', 'asset\_unpublished', 'entry\_unpublished', 'asset\_deleted', 'entry\_deleted', 'content\_type\_deleted'

Fetching the next batch of entries using pagination token

Performing subsequent sync after initial sync

## Stack

Stack API Key.

Stack Delivery token.

Stack Environment name.

Stack API Key.

Stack Delivery token.

Stack Environment name.

## Stack | JavaScript Browser Delivery SDK | Contentstack

The Stack class in the JavaScript Browser Delivery SDK initializes a stack instance, the main interface for retrieving content from your Contentstack stack.