# @volar/kit

> ```ts import * as fs from 'fs'; import * as path from 'path'; import { watch } from 'chokidar'; import * as kit from '@volar/kit';

Latest version **2.4.32** (published 2026-12-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install @volar/kit
pnpm add @volar/kit
yarn add @volar/kit
bun add @volar/kit
```

## Health

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

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

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.4.32 |
| Published | 2026-12-04 |
| First published | 2023-01-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 28.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1265 |
| Maintainers | johnsoncodehk |

## Links

- npm: https://www.npmjs.com/package/@volar/kit
- Repository: https://github.com/volarjs/volar.js
- Homepage: https://github.com/volarjs/volar.js#readme
- Issues: https://github.com/volarjs/volar.js/issues
- npm.io page: https://npm.io/package/@volar/kit

## Dependencies (5)

- [vscode-uri](https://npm.io/package/vscode-uri.md) ^3.0.8
- [typesafe-path](https://npm.io/package/typesafe-path.md) ^0.2.2
- [@volar/typescript](https://npm.io/package/@volar/typescript.md) 2.4.32
- [@volar/language-service](https://npm.io/package/@volar/language-service.md) 2.4.32
- [vscode-languageserver-textdocument](https://npm.io/package/vscode-languageserver-textdocument.md) ^1.0.11

## Recent versions

- 2.4.32 (latest) — 2026-12-04
- 2.4.32-alpha.0 (next) — 2026-12-04
- 2.4.31 — 2026-11-06
- 2.4.30 — 2026-10-22
- 2.4.29 — 2026-10-22
- 2.4.28 — 2026-01-31
- 2.4.27 — 2025-12-10
- 2.4.26 — 2025-11-25
- 2.4.25 — 2025-11-25
- 2.4.24 — 2025-11-25
- 2.4.23 — 2025-08-08
- 2.4.22 — 2025-07-27
- 2.4.21 — 2025-07-27
- 2.4.20 — 2025-07-18
- 2.4.19 — 2025-07-15
- … 200 more at https://npm.io/package/@volar/kit/versions

## README

# Kit

## Example: Use FileWatcher

```ts
import * as fs from 'fs';
import * as path from 'path';
import { watch } from 'chokidar';
import * as kit from '@volar/kit';

const tsconfig = getTsconfig();
const project = kit.createProject(tsconfig, [{ extension: 'foo', isMixedContent: true, scriptKind: 7 }]);
const config: kit.Config = {
    languages: {
        // ...
    },
    services: {
        // ...
    },
};
const linter = kit.createLinter(config, project.languageServiceHost);

let req = 0;

update();

createWatcher(path.dirname(tsconfig), ['ts', 'js', 'foo'])
    .on('add', (fileName) => {
        project.fileCreated(fileName);
        update();
    })
    .on('unlink', (fileName) => {
        project.fileDeleted(fileName);
        update();
    })
    .on('change', (fileName) => {
        project.fileUpdated(fileName);
        update();
    });

function createWatcher(rootPath: string, extension: string[]) {
    return watch(`${rootPath}/**/*.{${extension.join(',')}}`, {
        ignored: (path) => path.includes('node_modules'),
        ignoreInitial: true
    });
}

async function update() {

    const currentReq = ++req;
    const isCanceled = () => currentReq !== req;
    await new Promise(resolve => setTimeout(resolve, 100));
    if (isCanceled()) return;

    process.stdout.write('\x1Bc'); // clear console

    let hasError = false;
    for (const fileName of project.languageServiceHost.getScriptFileNames()) {
        const errors = await linter.check(fileName);
        if (isCanceled()) return;
        if (errors.length) {
            linter.logErrors(fileName, errors);
            hasError = true;
        }
    }
    if (!hasError) {
        console.log('No errors');
    }
}

function getTsconfig() {

    let tsconfig = path.resolve(process.cwd(), './tsconfig.json');

    const tsconfigIndex = process.argv.indexOf('--tsconfig');
    if (tsconfigIndex >= 0) {
        tsconfig = path.resolve(process.cwd(), process.argv[tsconfigIndex + 1]);
    }

    if (!fs.existsSync(tsconfig)) {
        throw `tsconfig.json not found: ${tsconfig}`;
    }

    return tsconfig;
}
```

## Create Project without tsconfig.json

```ts
const rootPath = process.cwd();
const fileNames = [
	path.resolve(rootPath, './src/a.ts'),
	path.resolve(rootPath, './src/b.js'),
	path.resolve(rootPath, './src/c.foo'),
];
const project = kit.createInferredProject(rootPath, fileNames);
```

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