# @line/liff-mock

> Make testing your LIFF app easy

Latest version **1.1.0** (published 2026-10-26) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @line/liff-mock
pnpm add @line/liff-mock
yarn add @line/liff-mock
bun add @line/liff-mock
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2026-10-26 |
| First published | 2022-04-15 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 78.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | lycorp-liff-team, lycorpall |
| Keywords | LIFF |

## Links

- npm: https://www.npmjs.com/package/@line/liff-mock
- npm.io page: https://npm.io/package/@line/liff-mock

## Recent versions

- 1.1.0 (latest) — 2026-10-26
- 1.0.4 — 2025-11-17
- 1.0.3 — 2022-11-11
- 1.0.2 — 2022-06-13
- 1.0.1 — 2022-05-17
- 1.0.0 — 2022-04-25
- 0.0.3 — 2022-04-15
- 0.0.2 — 2022-04-15
- 0.0.1 — 2022-04-15

## README

# LIFF Mock

LIFF Mock is a LIFF Plugin that make testing your LIFF app easy.

**※ LIFF Plugin feature is available since LIFF SDK v2.19.0.**

> [!WARNING]
> LIFF SDK versions v2.20.0 through v2.31.0 contain a security vulnerability. If you are using an affected version, upgrade to v2.31.1 or later. For details, see the [security advisory](https://developers.line.biz/en/news/2026/10/20/liff-sdk-issue/).

# Usage

## NPM

```sh
$ npm install @line/liff-mock
```

```ts
import liff from '@line/liff';
import { LiffMockPlugin } from '@line/liff-mock';

liff.use(new LiffMockPlugin());

liff.init({
  liffId: 'liff-xxxx',
  mock: true, // enable mock mode
});

if (!liff.isInClient()) liff.login();
const profile = await liff.getProfile();
// { displayName: 'Brown', userId: '123456789', statusMessage: 'hello' }
console.log(profile);
```

### With [Pluggable SDK](https://developers.line.biz/en/docs/liff/pluggable-sdk/)

If you use LIFF Mock with Pluggable SDK mode, you have to install `IsInClientModule` before the installation of `LiffMockPlugin` because LIFF Mock depends on `liff.isInClient` API.

```ts
import liff from '@line/liff/core';
import IsInClientModule from '@line/liff/is-in-client';
import { LiffMockPlugin } from '@line/liff-mock';

liff.use(new IsInClientModule()); // <-- Please install IsInClientModule before LiffMockPlugin
liff.use(new LiffMockPlugin());

liff.init({
  liffId: 'liff-xxxx',
  mock: true, // enable mock mode
});

if (!liff.isInClient()) liff.login();
const profile = await liff.getProfile();
// { displayName: 'Brown', userId: '123456789', statusMessage: 'hello' }
console.log(profile);
```

## CDN

https://unpkg.com/@line/liff-mock@1.1.0/dist/umd/liff-mock.js

```html
<!-- in <head> tag -->
<script src="https://unpkg.com/@line/liff-mock@1.1.0/dist/umd/liff-mock.js"></script>
```

```js
const liff = window.liff;
const liffMockPlugin = window.liffMock;

liff.use(new LiffMockPlugin());

liff.init({
  liffId: 'liff-xxxx',
  mock: true, // enable mock mode
});

if (!liff.isInClient()) liff.login();
const profile = await liff.getProfile();
// { displayName: 'Brown', userId: '123456789', statusMessage: 'hello' }
console.log(profile);
```

# API

## liff.$mock.set

Set mock data

```ts
type set = (
  data: Partial<MockData> | ((prev: Partial<MockData>) => Partial<MockData>)
) => void;
```

```js
const profile = await liff.getProfile();
// { displayName: 'Brown', userId: '123456789', statusMessage: 'hello' }
console.log(profile);

liff.$mock.set((p) => ({
  ...p,
  getProfile: { displayName: 'Cony', userId: '1111111' },
}));

const profile = await liff.getProfile();
// { displayName: 'Cony', userId: '1111111' }
console.log(profile);
```

## liff.$mock.clear

Restore default mock data

```ts
type clear: () => void;
```

```js
// liff.$mock.set(...)
const profile = await liff.getProfile();
// { displayName: 'Cony', userId: '1111111' }
console.log(profile);

liff.$mock.clear();

const profile = await liff.getProfile();
// { displayName: 'Brown', userId: '123456789', statusMessage: 'hello' }
console.log(profile);
```

# Example

See [examples](./examples)

# Contribution

```sh
$ nvm use
$ npm ci
```

---
_Source: https://npm.io/package/@line/liff-mock · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
