Sign In

@foldkit/vite-plugin

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@foldkit/vite-plugin

Vite plugin for Foldkit hot module reloading with state preservation

Source
npmnpm
Version
0.4.1
Version published
Weekly downloads
3.7K
-23.56%
Maintainers
1
Weekly downloads
 
Created
Source

@foldkit/vite-plugin

Vite plugin for Foldkit that enables hot module reloading with model preservation.

Installation

npm install -D @foldkit/vite-plugin
# or
pnpm add -D @foldkit/vite-plugin
# or
yarn add -D @foldkit/vite-plugin

Usage

Add the plugin to your vite.config.ts:

import { foldkit } from '@foldkit/vite-plugin'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [foldkit()],
})

What it does

When you save a file during development, the plugin:

  • Preserves your application's current state (model)
  • Triggers a full page reload
  • Restores the preserved model after reload

This means you can make code changes without losing your application's state - forms stay filled, counters keep their values, game positions are maintained, etc.

How it works

The plugin uses Vite's WebSocket connection to communicate between the dev server and browser:

  • On file change: The browser sends the current model to the Vite server for preservation
  • On reload: The browser requests the preserved model from the server and initializes the Foldkit runtime with it

Model is preserved across hot reloads but cleared on manual browser refreshes, giving you control over when to reset your app.

DevTools MCP relay

Pass devToolsMcpPort to enable the relay that exposes your running Foldkit app to AI agents via the @foldkit/devtools-mcp MCP server:

plugins: [foldkit({ devToolsMcpPort: 9988 })]

When set, the plugin opens a separate WebSocket server on the given port. The MCP server connects to it and forwards typed Request and Response frames between AI agents and your runtime. Without devToolsMcpPort (the default), the relay is not started and the plugin behaves exactly as before.

See the DevTools MCP documentation for setup, the available tools, and how dispatch validation works.

License

MIT

Keywords

vite

FAQs

Package last updated on 05 May 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts