Installations
npm install vite-plugin-json-server
Developer Guide
Typescript
Yes
Module System
ESM
Node Version
16.19.1
NPM Version
8.19.3
Score
44.7
Supply Chain
77
Quality
71
Maintenance
50
Vulnerability
98.6
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (88.88%)
HTML (5.75%)
JavaScript (5.37%)
validate.email 🚀
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Developer
yracnet
Download Statistics
Total Downloads
2,314
Last Day
2
Last Week
6
Last Month
45
Last Year
1,964
GitHub Statistics
MIT License
7 Stars
5 Commits
1 Forks
2 Watchers
1 Branches
1 Contributors
Updated on Dec 18, 2024
Bundle Size
892.71 kB
Minified
306.26 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.1.1
Package Id
vite-plugin-json-server@0.1.1
Unpacked Size
13.69 kB
Size
4.49 kB
File Count
6
NPM Version
8.19.3
Node Version
16.19.1
Published on
Jun 26, 2023
Total Downloads
Cumulative downloads
Total Downloads
2,314
Last Day
0%
2
Compared to previous day
Last Week
-25%
6
Compared to previous week
Last Month
-60.5%
45
Compared to previous month
Last Year
461.1%
1,964
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Peer Dependencies
1
Dev Dependencies
6
vite-plugin-json-server
Description
vite-plugin-json-server is a plugin for Vite.js that integrates the json-server library, providing a simple way to serve a mock RESTful API during development. It enables you to quickly set up a server and define JSON data as endpoints, allowing you to simulate backend functionality without the need for a real server. This plugin is designed to seamlessly integrate with Vite.js, leveraging its fast and efficient development server. By combining the power of Vite.js and json-server, you can streamline your frontend development process and focus on building your application.
Motivation
During frontend development, it is often necessary to work with an API before the actual backend is ready or available. This can cause delays and hinder the development process. With vite-plugin-json-server, you can overcome this hurdle by creating a mock API server with minimal effort. It allows you to define your data, endpoints, and even custom routes, providing a flexible and efficient solution for frontend development.
How to Use
- Install the plugin using npm or yarn:
1npm install vite-plugin-json-server --save-dev
or
1yarn add vite-plugin-json-server --dev
- Import and use the plugin in your
vite.config.js
file:
1import jsonServer from "vite-plugin-json-server"; 2export default { 3 plugins: [ 4 jsonServer({ 5 // Configuration options 6 }), 7 ], 8};
- Start your Vite development server:
1npm run dev
- Your mock API server will be available at
http://localhost:5173
by default.
Configuration
The plugin supports the following configuration options:
apiPath
: The base path for publishing json-server services. Default value: '/api'.profile
: The profile name as directory name where other files are referenced. It can be used to customize data profile as needed. The default value is an empty string. You can use 'db-dev' or 'db1' as profile names.source
: The resource to load and pass as main parameters to json-server. It is used withjoin(profile, source)
when compiling.static
: The name of the profile that contains static files. It is derived fromjoin(profile, source)
.unwatch
: An inverse flag for thewatch
option that monitors and reloads the server when changes are detected.readOnly
: A flag for json-server to enable read-only mode.bodyParser
: A flag for json-server to enable body parsing.noCors
: A flag for json-server to disable CORS (Cross-Origin Resource Sharing).noGzip
: A flag for json-server to disable Gzip compression.delay
: The delay value for json-server to simulate network latency.id
: The value for json-server'sid
option.foreignKeySuffix
: The value for json-server'sforeignKeySuffix
option.quiet
: The value for json-server'squiet
option. Please refer to the json-server documentation for more details on these configuration options.
Note: The following options are not yet supported by the plugin and will be implemented in a future version: routes
, snapshots
, and middlewares
.
Note: The host
and port
options are excluded form the plugin.
License
This plugin is licensed under the MIT License.

No vulnerabilities found.

No security vulnerabilities found.