Nimiq Web Client Vite Integration

Integrate Nimiq Web Client with Vite for fast blockchain development with minimal configuration.

Quick Start with Templates

Get started instantly with our pre-configured starter templates:

bash
npx degit onmax/nimiq-starter/starters/vue-ts my-nimiq-app
cd my-nimiq-app && pnpm install && pnpm dev
bash
npx degit onmax/nimiq-starter/starters/react-ts my-nimiq-app
cd my-nimiq-app && pnpm install && pnpm dev

Installation

Install the Nimiq Web Client:

bash
pnpm add @nimiq/core
bash
npm install @nimiq/core
bash
yarn add @nimiq/core
bash
bun add @nimiq/core

Configuration

The Nimiq Web Client includes a Vite plugin that automatically configures WebAssembly support and all required optimizations.

TIP

View the plugin source code for implementation details.

Update your vite.config.ts:

ts
import nimiq from '@nimiq/core/vite'
import { defineConfig } from 'vite'

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

The plugin automatically configures:

  • WebAssembly support with vite-plugin-wasm
  • Worker configuration for WASM modules (opt-out via { worker: false })
  • Build target optimizations (esnext)
  • Dependency exclusions for @nimiq/core
Legacy Browser Support

Modern browsers (Chrome 89+, Firefox 89+, Safari 15+, Edge 89+) support top-level await natively. If you need to support older browsers, install vite-plugin-top-level-await:

bash
pnpm add -D vite-plugin-top-level-await
bash
npm install -D vite-plugin-top-level-await
bash
yarn add -D vite-plugin-top-level-await
bash
bun add -D vite-plugin-top-level-await

Then add it to your Vite config:

ts
import nimiq from '@nimiq/core/vite'
import { defineConfig } from 'vite'
import topLevelAwait from 'vite-plugin-top-level-await'

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

NOTE

Top-level await is required for ES modules when using dynamic WASM imports. The plugin transforms top-level await to work in older browsers.

Usage Example

js
import init, { Client, ClientConfiguration } from '@nimiq/core/web'

await init()

const config = new ClientConfiguration()
const client = await Client.create(config.build())

await client.waitForConsensusEstablished()
Built with the Nimiq Vitepress Theme
Copy page
Report a bug
Send feedback