> For the complete documentation index, see [llms.txt](https://developers-apps-in-toss.toss.im/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-en/sdk/v3.md).

# v3

`@apps-in-toss/web-framework` 3.0.0 `latest`was deployed as. Now `npm install @apps-in-toss/web-framework`If you run it, 3.0.0 will be installed.

3.0.0 is a major update that restructured the SDK to suit web mini app development. In this document, you can see the differences between 2.x and 3.0.0.

### At a glance

* The public API has been reorganized around domain objects. Existing functions grouped by domain are kept as deprecated, so they continue to work without code changes.
* The package has become lighter. The install size has been reduced from about 27MB to about 660KB.
* The config file `granite.config.ts`in `apps-in-toss.config.ts`has been changed to. `npx ait migrate v3` You can automatically convert it with the command.
* Sandbox apps do not support 3.0. We plan to support devtools that mock APIs. Until then, please test in the Toss app using the QR code issued in the console.

### Domain object API

In 3.0.0, the public API is grouped into feature-specific domain objects. Existing individual functions grouped by domain are now deprecated, so please use the corresponding domain members instead.

```typescript
// 2.x style — it works, but a deprecated warning is shown.
import { openCamera } from "@apps-in-toss/web-framework";
const image = await openCamera();

// 3.0 style
import { Device } from "@apps-in-toss/web-framework";
const image = await Device.openCamera();
```

Existing functions behave exactly the same as in 2.x, from the function name to the input and output values. So 2.x code compiles and works in 3.0 without modification. However, the editor will show it as deprecated, and we recommend writing new code with domain members.

#### Mapping table between existing APIs and domain members

| Domain       | Existing API (deprecated)          | New API                         |
| ------------ | ---------------------------------- | ------------------------------- |
| Clipboard    | `getClipboardText`                 | `Clipboard.getText`             |
| Clipboard    | `setClipboardText`                 | `Clipboard.setText`             |
| Device       | `fetchAlbumItems`                  | `Device.getAlbumItems`          |
| Device       | `fetchAlbumPhotos`                 | `Device.getPhotos`              |
| Device       | `fetchContacts`                    | `Device.getContacts`            |
| Device       | `getCurrentLocation`               | `Device.getLocation`            |
| Device       | `getLocale`                        | `Device.locale`                 |
| Device       | `getPlatformOS`                    | `Device.os`                     |
| Device       | `generateHapticFeedback`           | `Device.triggerHaptic`          |
| Device       | `openCamera`                       | `Device.openCamera`             |
| Device       | `openURL`                          | `Device.openURL`                |
| Device       | `startUpdateLocation`              | `Device.subscribeLocation`      |
| Environment  | `getDeviceId`                      | `Environment.deviceId`          |
| Environment  | `getGroupId`                       | `Environment.groupId`           |
| Environment  | `getOperationalEnvironment`        | `Environment.environment`       |
| Environment  | `getTossAppVersion`                | `Environment.tossAppVersion`    |
| Environment  | `env.getDeploymentId`              | `Environment.deploymentId`      |
| Environment  | `getSchemeUri`                     | `Environment.initialURL`        |
| Environment  | `getNetworkStatus`                 | `Environment.getNetworkStatus`  |
| Environment  | `getServerTime`                    | `Environment.getServerTime`     |
| File         | `saveBase64Data`                   | `File.saveBase64`               |
| File         | `openPDFViewer`                    | `File.openPDFViewer`            |
| Game         | `openGameCenterLeaderboard`        | `Game.openLeaderboard`          |
| Game         | `submitGameCenterLeaderBoardScore` | `Game.setLeaderboardScore`      |
| Game         | `getGameCenterGameProfile`         | `Game.getUserProfile`           |
| Game         | `getUserKeyForGame`                | `User.getAnonymousKey`          |
| Game         | `grantPromotionRewardForGame`      | `Promotion.grantReward`         |
| Notification | `requestNotificationAgreement`     | `Notification.requestAgreement` |
| Promotion    | `grantPromotionReward`             | `Promotion.grantReward`         |
| Promotion    | `contactsViral`                    | `Promotion.openContactsInvite`  |
| Review       | `requestReview`                    | `Review.request`                |
| SafeArea     | `getSafeAreaInsets`                | `SafeArea.get`                  |
| SafeArea     | `SafeAreaInsets.subscribe`         | `SafeArea.subscribe`            |
| Screen       | `closeView`                        | `Screen.close`                  |
| Screen       | `setScreenAwakeMode`               | `Screen.setAwakeMode`           |
| Screen       | `setSecureScreen`                  | `Screen.setSecure`              |
| Screen       | `setIosSwipeGestureEnabled`        | `Screen.setIosSwipeBack`        |
| Screen       | `setDeviceOrientation`             | `Screen.setOrientation`         |
| Share        | `getTossShareLink`                 | `Share.createLink`              |
| Share        | `share`                            | `Share.sendMessage`             |
| TossAuth     | `appLogin`                         | `TossAuth.login`                |
| TossAuth     | `getIsTossLoginIntegratedService`  | `TossAuth.isIntegrated`         |
| TossAuth     | `appsInTossSignTossCert`           | `TossAuth.sign`                 |
| TossPay      | `checkoutPayment`                  | `TossPay.authorize`             |
| TossPay      | `requestTossPayPaysBilling`        | `TossPay.authorizeSubscription` |
| User         | `getAnonymousKey`                  | `User.getAnonymousKey`          |
| User         | `getConsentedUserData`             | `User.getConsentedData`         |
| User         | `getDeclaredAgeRange`              | `User.getDeclaredAgeRange`      |

`SafeAreaInsets`is `SafeArea`It's an object like this. You can continue to use the existing name as is.

#### APIs that remain unchanged

The following APIs are not grouped by domain and are provided in the existing form as is. You can keep using them without deprecation.

* Object-based APIs: `IAP`, `Storage`, `TossAds`, `GoogleAdMob`, `Analytics`, `partner`
* Ads: `loadFullScreenAd`, `showFullScreenAd`
* Permissions: `getPermission`, `requestPermission`, `openPermissionDialog`and permission error classes
* Events: `appsInTossEvent`, `graniteEvent`, `tdsEvent`
* Environment: `isMinVersionSupported`, `getAppsInTossGlobals`

#### New APIs

* `PermissionError`: The common parent class for permission errors has been made public. `error instanceof PermissionError`can handle all permission errors at once.
* `TossPay` Domain objects: In 2.x, `checkoutPayment` there were only the same individual functions, but in 3.0 they are `TossPay.authorize`, `TossPay.authorizeSubscription`grouped into

#### Differences in behavior between existing functions and domain members

It's not just a name change; some behavioral contracts have also been improved. Please check the following differences when migrating.

* Constant APIs are read as properties, not called as functions. For example `getLocale()`is `Device.locale`becomes, `getDeviceId()`is `Environment.deviceId`changes to.
* On Toss app versions that do not support domain members, `UNSUPPORTED_APP_VERSION` or `UNSUPPORTED_OS_VERSION` with an error code. Existing functions return values like `undefined`or `'ERROR'` under the 2.x contract. For example `getAnonymousKey`returns `'ERROR'`on failure, `User.getAnonymousKey`throws an error. `error.code`you can branch on it and show guidance like "Please update the Toss app".
* `Share.createLink`takes an object argument. `getTossShareLink(path, ogImageUrl)`is `Share.createLink({ path, ogImageUrl })`changes to.
* `IAP.createOneTimePurchaseOrder` The product identifier in the response uses `sku`. `productId` The field has been deprecated.

### Config file changes

The config file name has been changed to `granite.config.ts`in `apps-in-toss.config.ts`and some options have changed.

| 2.x (`granite.config.ts`)         | 3.0 (`apps-in-toss.config.ts`) | Description                                                                                |
| --------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------ |
| `web` (host, port, commands)      | removed                        | The dev server and build execution have been moved from the SDK to `package.json` scripts. |
| `brand.displayName`, `brand.icon` | removed                        | `brand`contains `primaryColor`remain.                                                      |
| `webViewProps`                    | `webView`                      | has been renamed. The sub-options are the same, and `type`only removed.                    |
| `webViewProps.type`               | removed                        | The WebView frame type option has been removed.                                            |
| `outdir`                          | `webBundleDir`                 | Only the name changed. The default is `dist`the same.                                      |

The config type name has also `AppsInTossWebConfig`in `AppsInTossConfig`has been changed to.

The web dev server and build now run directly from the `package.json` scripts.

```json
{
  "scripts": {
    "dev": "vite dev",
    "build": "vite build && ait build",
    "deploy": "ait deploy"
  }
}
```

### Package structure changes

| Item          | 2.x               | 3.0                                                                 |
| ------------- | ----------------- | ------------------------------------------------------------------- |
| Install size  | About 27MB        | About 660KB                                                         |
| Module format | ESM only          | Dual ESM + CJS                                                      |
| dependencies  | 13                | 4 (`@apps-in-toss/cli`, `@webview-bridge/web`, `semver`, `valibot`) |
| License       | Only LICENSE file | `Apache-2.0` specified                                              |

CJS environments (`require`, old bundlers) as well, and with fewer dependencies, installation is faster and concerns about version conflicts with other packages are reduced.

### Sandbox and development environment mocking

Sandbox apps do not support 3.0. Instead, we're preparing to provide devtools soon so APIs can be mocked in a local development environment without the sandbox app.

Until then, please test mini apps made with 3.0 in the Toss app using the QR code issued from the Apps in Toss console.

### Migrating to 3.0.0

We provide an automatic migration command. Config file conversion and `package.json` script restructuring are handled automatically.

```bash
npx ait migrate v3
```

This command performs the following tasks.

* `granite.config.ts`changed `apps-in-toss.config.ts`to (`brand`is `primaryColor`keep only, `webViewProps`is `webView`change to, `outdir`is `webBundleDir`change to, `web` delete blocks).
* `package.json`the `dev`, `build` Restructures scripts.
* If validation fails before conversion, the file is not changed and the cause and solution are shown.

After migrating, upload the bundle to the console and test it in the Toss app with a QR code.

#### Please make sure to check

* Once you release a bundle built with SDK 3.x, you cannot roll back to 2.x. Please test thoroughly with QR codes before releasing.
* Starting from 3.0, the mini app runs from `https://<appName>.web.tossmini.com`(Live) and `https://<appName>.private-web.tossmini.com`(QR Test) Origin. Please register both domains in the API server's CORS allowlist.
* If you use TDS, `@toss/tds-mobile`and `@toss/tds-mobile-ait`please update it to 2.4.1 or later as well.
* 3.0.0-rc.1 and rc.2 cannot be installed due to dependency issues. Please use the official 3.0.0 version.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-en/sdk/v3.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
