---
name: "createCameraContext"
mode: "api"
versionRequirements:
  - { name: "Base Library", version: "2.21.8" }
title: "ty.createCameraContext"
---

## createCameraContext

> [VERSION] Base Library >= 2.21.8

> 💡 The returned CameraContext is bound to the camera component in the page and can take photos, record video, set zoom, and more.

### Description

Create a camera context (CameraContext) object

### Parameters

None


### Return Value

Type: `CameraContext`

CameraContext instance

### Examples

#### Create camera context

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