---
updatedAt: 2026-03-19T19:38:50.000Z
agentTools:
  projectIndex: https://developers.miro.com/llms.txt
---

# Viewport

## Methods

### get(...)

<pre class="sdk-reference-type">() =&gt; Promise&lt;Rect&gt;</pre>

##### 🔒 Requires scope: [boards:read](https://developers.miro.com/reference/scopes#boardsread "boards:read") or [boards:write](https://developers.miro.com/reference/scopes#boardswrite "boards:write")

Fetches the dimensions of the current viewport and its position, relative to the center of board with `x: 0` and `y: 0`.

The viewport `x` and `y` coordinates define the horizontal and vertical position of the top-left corner of the viewport, relative to the center point of the board with `x: 0` and `y: 0`.
Values are in [dp](https://en.wikipedia.org/wiki/Device-independent_pixel).

The method takes no arguments.

Example:

```typescript
// Get the current viewport.
const viewport = await miro.board.viewport.get();

// Print coordinates and dimensions of the current viewport.
console.log(viewport);
// {
//   x: -29570.817261000782,
//   y: -18247.315051361205,
//   width: 64157.213365973126,
//   height: 32763.49326537
// }
```

### set(...)

<pre class="sdk-reference-type">(options: { animationDurationInMs?: number; padding?: Offset; <a href="#viewport" title="viewport">viewport</a>: Rect }) =&gt; Promise&lt;Rect&gt;</pre>

##### 🔒 Requires scope: [boards:read](https://developers.miro.com/reference/scopes#boardsread "boards:read") or [boards:write](https://developers.miro.com/reference/scopes#boardswrite "boards:write")

Updates the dimensions of the viewport and its position, relative to the center of board with `x: 0` and `y: 0`.

There can be a discrepancy between the input that you pass to `viewport.set()`, and the corresponding output.
The output depends on specific factors such as the actual screen size, any vertical or horizontal navigation bars, and so on.

#### viewport

The method takes `viewport` as a required argument:

| Property |  Type  | Description                                                                                                                                                             |
| :------- | :----: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `x`      | Number | Horizontal position of the top-left corner of the viewport, relative to the center point of the board, in [dp](https://en.wikipedia.org/wiki/Device-independent_pixel). |
| `y`      | Number | Vertical position of the top-left corner of the viewport, relative to the center point of the board, in dp.                                                             |
| `width`  | Number | Width of the viewport, in dp.                                                                                                                                           |
| `height` | Number | Height of the viewport, in dp.                                                                                                                                          |

The method takes `padding` and `animationDurationInMs` as optional arguments.

#### padding

`padding` is an object with the following optional properties:

| Property |  Type  | Description                                                                    |
| :------- | :----: | :----------------------------------------------------------------------------- |
| `top`    | Number | Padding area above the target viewport, in dp.<br>Default: `0` (no padding)    |
| `bottom` | Number | Padding area below the target viewport, in dp.<br>Default: `0` (no padding)    |
| `right`  | Number | Padding area right of the target viewport, in dp.<br>Default: `0` (no padding) |
| `left`   | Number | Padding area left of the target viewport, in dp.<br>Default: `0` (no padding)  |

#### animationDurationInMs

`animationDurationInMs` defines the duration in milliseconds of a zoom animation effect that plays when setting the viewport.
Default: `0` (no animation)

Example:

```typescript
const myViewport = await miro.board.viewport.set({
  viewport: {
    x: 200, // top-left corner of the viewport, relative to the center of the board
    y: 100, // top-left corner of the viewport, relative to the center of the board
    width: 1280,
    height: 720,
  },
  padding: {
    top: 100,
    left: 200,
    bottom: 50,
    right: 20,
  },
  animationDurationInMs: 1000,
});

console.log(myViewport); // => {x: 224.2903225806451, y: 119.00000000000003, width: 1328.5806451612902, height: 718.7872340425532}
```

### zoomTo(...)

<pre class="sdk-reference-type">(items: OneOrMany&lt;BaseItem&gt;) =&gt; Promise&lt;void&gt;</pre>

##### 🔒 Requires scope: [boards:read](https://developers.miro.com/reference/scopes#boardsread "boards:read") or [boards:write](https://developers.miro.com/reference/scopes#boardswrite "boards:write")

Zooms to one or more items on the board.
If you zoom to items that are scattered across the board, the method can zoom out to include in the viewport all the items that you pass as arguments.
If you don't pass any items as arguments, the method throws an error.

Example:

```typescript
// Create three sticky notes
const first = await miro.board.createStickyNote({
  content: 'first',
  x: 400,
  y: 400,
});

const second = await miro.board.createStickyNote({
  content: 'second',
  x: -400,
  y: -400,
});

const third = await miro.board.createStickyNote({
  content: 'third',
});

// Zoom to a sticky note on the board
await miro.board.viewport.zoomTo(first);

// Or: zoom to multiple sticky notes on the board
await miro.board.viewport.zoomTo([second, third]);

// Or: zoom to all sticky notes on the board
const stickyNotes = await miro.board.get({
  type: 'sticky_note',
});

await miro.board.viewport.zoomTo(stickyNotes);
```

### getZoom(...)

<pre class="sdk-reference-type">() =&gt; Promise&lt;number&gt;</pre>

##### 🔒 Requires scope: [boards:read](https://developers.miro.com/reference/scopes#boardsread "boards:read") or [boards:write](https://developers.miro.com/reference/scopes#boardswrite "boards:write")

Returns the current zoom level on the board.
The method takes no arguments.

Example:

```typescript
// Get the current zoom level.
const zoomLevel = await miro.board.viewport.getZoom();

// Print the current zoom level.
console.log(zoomLevel);
```

### setZoom(...)

<pre class="sdk-reference-type">(zoomLevel: number) =&gt; Promise&lt;void&gt;</pre>

##### 🔒 Requires scope: [boards:read](https://developers.miro.com/reference/scopes#boardsread "boards:read") or [boards:write](https://developers.miro.com/reference/scopes#boardswrite "boards:write")

Updates the zoom level on the board.

The method takes `zoomLevel` as a required argument.
The `zoomLevel` accepts a value between `0.01` (1% zoom on the board UI) and `4` (400% zoom on the board UI).

Example:

```typescript
// Set the zoom level to 400%.
await miro.board.viewport.setZoom(4);
// The board will be zoomed at 400%.
```

## All properties

<table><tr><th>Property</th><th>Type</th></tr>
<tr>
  <td><code>get(...)</code></td>
  <td>
    <pre class="sdk-reference-type">() =&gt; Promise&lt;Rect&gt;</pre>
  </td>
</tr>
<tr>
  <td><code>getZoom(...)</code></td>
  <td>
    <pre class="sdk-reference-type">() =&gt; Promise&lt;number&gt;</pre>
  </td>
</tr>
<tr>
  <td><code>set(...)</code></td>
  <td>
    <pre class="sdk-reference-type">(options: { animationDurationInMs?: number; padding?: Offset; <a href="#viewport" title="viewport">viewport</a>: Rect }) =&gt; Promise&lt;Rect&gt;</pre>
  </td>
</tr>
<tr>
  <td><code>setZoom(...)</code></td>
  <td>
    <pre class="sdk-reference-type">(zoomLevel: number) =&gt; Promise&lt;void&gt;</pre>
  </td>
</tr>
<tr>
  <td><code>zoomTo(...)</code></td>
  <td>
    <pre class="sdk-reference-type">(items: OneOrMany&lt;BaseItem&gt;) =&gt; Promise&lt;void&gt;</pre>
  </td>
</tr></table>

# Sibling pages

* [Interact with boards and items](https://developers.miro.com/miro-ea/docs/websdk-reference-interact-with-boards-and-items.md)
* [Rate limiting](https://developers.miro.com/miro-ea/docs/websdk-reference-rate-limiting.md)
* [Error handling](https://developers.miro.com/miro-ea/docs/websdk-reference-error-handling.md)
* [Board](https://developers.miro.com/miro-ea/docs/websdk-reference-board.md)
* [Card](https://developers.miro.com/miro-ea/docs/websdk-reference-card.md)
* [Board UI](https://developers.miro.com/miro-ea/docs/websdk-reference-ui.md)
* [Notifications](https://developers.miro.com/miro-ea/docs/websdk-reference-notifications.md)
* [App card](https://developers.miro.com/miro-ea/docs/websdk-reference-app-card.md)
* [Experimental](https://developers.miro.com/miro-ea/docs/websdk-reference-experimental.md)
* [Realtime Events](https://developers.miro.com/miro-ea/docs/websdk-reference-events.md)
* [Tag](https://developers.miro.com/miro-ea/docs/websdk-reference-tag.md)
* [Custom Action Management](https://developers.miro.com/miro-ea/docs/websdk-reference-custom-action-management.md)
* [Shape](https://developers.miro.com/miro-ea/docs/websdk-reference-shape.md)
* [Frame](https://developers.miro.com/miro-ea/docs/websdk-reference-frame.md)
* [Image](https://developers.miro.com/miro-ea/docs/websdk-reference-image.md)
* [Sticky Note](https://developers.miro.com/miro-ea/docs/websdk-reference-sticky-note.md)
* [Shape experimental](https://developers.miro.com/miro-ea/docs/websdk-reference-shape-experimental.md)
* [Embed](https://developers.miro.com/miro-ea/docs/websdk-reference-embed.md)
* [Connector](https://developers.miro.com/miro-ea/docs/websdk-reference-connector.md)
* [Unsupported](https://developers.miro.com/miro-ea/docs/websdk-reference-unsupported.md)
* [Mindmap Node](https://developers.miro.com/miro-ea/docs/websdk-reference-mindmap-node.md)
* [Preview](https://developers.miro.com/miro-ea/docs/websdk-reference-preview.md)
* [Text](https://developers.miro.com/miro-ea/docs/websdk-reference-text.md)
* [Storage collection](https://developers.miro.com/miro-ea/docs/websdk-reference-collection.md)
* [Storage](https://developers.miro.com/miro-ea/docs/websdk-reference-storage.md)
* [Collaboration](https://developers.miro.com/miro-ea/docs/websdk-reference-collaboration.md)
* [Session](https://developers.miro.com/miro-ea/docs/websdk-reference-session.md)
* [Attention](https://developers.miro.com/miro-ea/docs/websdk-reference-attention.md)
* [Group](https://developers.miro.com/miro-ea/docs/websdk-reference-group.md)
* [History](https://developers.miro.com/miro-ea/docs/websdk-reference-history.md)
* [Tools](https://developers.miro.com/miro-ea/docs/websdk-reference-tools.md)