Skip to content
PluginStats

mock-service-plugin weekly downloads statistics

By bianliuzhu · npm · Webpack plugins

Simulated backend interface service

View on npm Fresh · Dec 6, 2026

mock-service-plugin has 111 recorded weekly downloads on npm, an increase of 158% over the past 30 days, ranking #2601 of 3,247 tracked listings.

Weekly downloads
111
Official API · Dec 5, 2026
7-day growth
+56.3%
+40 weekly downloads
30-day growth
+158%
+68 weekly downloads
90-day growth
+383%
+88 weekly downloads
Rank
#2601
▼ 42 in 7 days

About mock-service-plugin

mock-service-plugin

English | 中文

A powerful local Mock service plugin that supports Webpack, Vite, and other mainstream build tools — letting you develop and debug frontend pages even before the backend APIs are ready.

Table of Contents


What is Mocking?

In real-world development, frontend and backend teams often work in parallel. When the backend APIs aren't ready yet, the frontend has no data to work with and development stalls.

Mocking means running a fake backend service locally that returns dummy data according to the agreed API contract, so frontend development can proceed independently without relying on a real backend.

What mock-service-plugin does is: read your mock data files, automatically start a local HTTP server, and return the corresponding data when frontend requests come in.


Features

  • 🚀 Supports multiple build tools: Webpack 4/5, Vite, Vue CLI, Create React App
  • 🎯 Compatible with Vue, React, and other mainstream frameworks
  • 🔥 Feature-rich
    • RESTful API support (GET / POST / PUT / DELETE, etc.)
    • Dynamic route parameters (e.g. /api/users/:id)
    • Streaming responses (SSE / EventStream, simulates AI typewriter effect)
    • Multiple response formats (JSON / XML / CSV / Image / Plain text, etc.)
  • 💡 Minimal configuration, hot reload, built-in debug interface

Installation

# npm
npm install mock-service-plugin --save-dev

# yarn
yarn add mock-service-plugin --dev

# pnpm
pnpm add mock-service-plugin --save-dev

5-Minute Quick Start

The following uses a Vite + Vue project as an example to walk you through your first Mock API from scratch.

Step 1: Install the Plugin
npm install mock-service-plugin --save-dev
Step 2: Create the Mock Directory and File

Create a mocks folder in the project root and add a file mocks/user.json:

project-root/
├── mocks/
│   └── user.json   ← create this file
├── src/
├── vite.config.ts
└── package.json

Contents of mocks/user.json:

/**
 * @url /api/user/info
 * @method GET
 */
{
  "code": 200,
  "data": {
    "id": "@id",
    "name": "@cname",
    "email": "@email",
    "avatar": "@image('100x100')"
  },
  "message": "success"
}

The /** ... */ comment at the top is the route configuration, telling the plugin which API path and HTTP method this file corresponds to.
@cname, @email, etc. are MockJS random data placeholders — each request generates different random data. See MockJS Syntax Reference for full syntax.

Step 3: Start the Mock Service in Vite

Create vite-mock-plugin.ts in the project root:

// vite-mock-plugin.ts
import { startServer } from "mock-service-plugin";
import { createServer } from "net";
import { join } from "path";

// Check if a port is already in use
function isPortTaken(port: number): Promise<boolean> {
  return new Promise((resolve) => {
    const server = createServer();
    server.once("error", (err: { code: string }) => {
      resolve(err.code === "EADDRINUSE");
    });
    server.once("listening", () => {
      server.close();
      resolve(false);
    });
    server.listen(port);
  });
}

// Vite plugin: start Mock service in mock mode
export default function ViteMockServicePlugin(mode: string) {
  return {
    name: "ViteMockServicePlugin",
    buildStart() {
      (async () => {
        const port = 3008;
        if (await isPortTaken(port)) {
          console.log(`[Mock] Port ${port} is already in use, skipping start`);
          return;
        }
        if (mode === "mock") {
          startServer({
            mockDir: join(__dirname, "./mocks"), // path to mock folder
            port, // mock service port
          });
        }
      })();
    },
  };
}

Update vite.config.ts:

// vite.config.ts
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import ViteMockServicePlugin from "./vite-mock-plugin";

export default defineConfig(({ mode }) => ({
  plugins: [
    vue(),
    ViteMockServicePlugin(mode), // pass current mode
  ],
  server: {
    proxy: {
      // Proxy /api requests to the mock service
      "/api": {
        target: "http://localhost:3008",
        changeOrigin: true,
      },
    },
  },
}));

Add a mock start script to package.json:

{
  "scripts": {
    "dev": "vite --mode dev",
    "mock": "vite --mode mock"
  }
}
Step 4: Start and Test
npm run mock

After starting, open http://localhost:3008/api/user/info in your browser and you'll see randomly generated user data:

{
  "code": 200,
  "data": {
    "id": "660000198812040277",
    "name": "Han Lei",
    "email": "c.wjjdmpyy@wfomlb.net",
    "avatar": "http://dummyimage.com/100x100"
  },
  "message": "success"
}

Congratulations! You've successfully set up your first Mock API. 🎉


Mock File Specification

File Structure

Each mock file consists of two parts:

file = top comment (route config) + response body
/**
 * @url /api/users        ← required: API path
 * @method GET            ← optional: HTTP method, defaults to GET
 */
{
  "code": 200,
  "data": []
}
Annotation Reference…

Description from the npm listing.

  • mock
  • mockjs
  • webpack-plugin
  • mock service
  • json server

README badge

Show your rank in a README or on your website. The badge updates automatically.

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

mock-service-plugin weekly downloads on npm, last 90 days: 111 weekly downloads as of Dec 5, 2026, +383% over 90 days.mock-service-pluginWeekly downloads on npm · Last 90 days111downloads / week+383% over 90 days050100150200250Sep 6Sep 21Oct 6Oct 21Nov 5Nov 20Dec 5downloads / weekobservedarchived (Internet Archive)no observationsSep 7, 2026 – Dec 5, 2026 · 90 observations · Updated Dec …pluginstats.com
mock-service-plugin weekly downloads on npm, last 90 days: 111 weekly downloads as of Dec 5, 2026, +383% over 90 days.

7/30/90-day growth

mock-service-plugin weekly downloads growth on npm: +56.3% over 7 days, +158% over 30 days, +383% over 90 days.mock-service-pluginWeekly downloads growth on npm111downloads / week now7-day growth+40 weekly downloads+56.3%30-day growth+68 weekly downloads+158%90-day growth+88 weekly downloads+383%Growth vs. nearest observation to each baseline date · Updated Dec 5, 2026pluginstats.com
mock-service-plugin weekly downloads growth on npm: +56.3% over 7 days, +158% over 30 days, +383% over 90 days.

Ranking history

mock-service-plugin npm ranking history: currently #2601 (by weekly downloads).mock-service-pluginnpm ranking · by weekly downloads · Last 90 days#2601current rank#1800#2000#2200#2400#2600#2800#3000Sep 7Sep 22Oct 7Oct 22Nov 6Nov 21Dec 6rankOct 18, 2026 – Dec 6, 2026 · 37 observations · Updated Dec 5, 2026pluginstats.com
mock-service-plugin npm ranking history: currently #2601 (by weekly downloads).

Listing placement

All npm3,247 listings · 163 pages · 1,084 shown · page 131, #1 (overall #2,601)
All npm: every listing in weekly downloads order

Listing placement

Webpack plugins349 listings · 18 pages · page 9, #11 (overall #171)
Webpack plugins: every listing in weekly downloads order

Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.

Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.

Recent observations

Full history (170)
Recent weekly downloads observations for mock-service-plugin
Date (UTC)Weekly downloadsChange vs. previous
111+93
18-6
24+2
220
22+1
21-48
69-2
71+1
70+3
67-2
69+3
66+1
65+50
15—

Similar npm Webpack plugins plugins

All 20 mock-service-plugin alternatives

Data source

Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.

Listing: https://www.npmjs.com/package/mock-service-plugin. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.