---
name: "CameraContext"
mode: "api"
versionRequirements:
  - { name: "Base Library", version: "2.21.8" }
title: "CameraContext"
---

## CameraContext

> [VERSION] Base Library >= 2.21.8

> 💡 CameraContext is bound to the camera component on the page and controls the corresponding camera

### Description

CameraContext instance, obtainable via ty.createCameraContext

### Parameters

None


### Return Value

Type: `CameraContext`

CameraContext instance

#### Methods

| Method | Description |
| --- | --- |
| `setZoom` | Set zoom level |
| `startRecord` | Start recording |
| `stopRecord` | Stop recording |
| `takePhoto` | Take photo |

### Examples

#### Basic usage

```ts
Page({
  onReady() {
    const cameraCtx = ty.createCameraContext();
    cameraCtx.takePhoto({
      quality: 'high',
      success(res) {
        console.log('Photo taken successfully', res);
      },
    });
  },
});
```
