Vite integration for NativeScript apps.
Documentation · Environment Setup · Contribute · Community
- NativeScript 9 or higher
npm i @nativescript/vite -DTo bootstrap an existing NativeScript app for Vite, run from your app root:
npx nativescript-vite initThis will:
- Generate a
vite.config.tsusing the detected project flavor (Angular, Vue, React, Solid, TypeScript, or JavaScript) and the corresponding helper from@nativescript/vite. - Add (or update) the following npm scripts in your app
package.json:dev:iosdev:androiddev:server:iosdev:server:androidiosandroid
- Add the devDependencies
concurrentlyandwait-on. - Add the dependency
@valor/nativescript-websockets. - Append
.ns-vite-buildto.gitignoreif it is not already present.
After running init, you now have two ways to work with Vite:
- HMR workflow
npm run dev:ios- Standard dev workflow (non-HMR)
ns debug ios --no-hmr
ns debug android --no-hmr- Create
vite.config.ts:
import { defineConfig, mergeConfig, UserConfig } from 'vite';
import { typescriptConfig } from '@nativescript/vite';
export default defineConfig(({ mode }): UserConfig => {
return mergeConfig(typescriptConfig({ mode }), {});
});- Update
nativescript.config.ts:
import { NativeScriptConfig } from '@nativescript/core';
export default {
// add these:
bundler: 'vite',
bundlerConfigPath: 'vite.config.ts',
} as NativeScriptConfig;- Enjoy Vite.
Check out the NativeScript Vite documentation for more configuration options and features.