Using npm Packages in Blazor Applications
This article integrates an existing JavaScript package into Blazor by placing its npm and Vite setup in a separate Razor Class Library. The library produces a bundled JavaScript asset that the application can call through JS interop.
Ruslan Dudchenko demonstrates the approach with simple-statistics, connecting the frontend build to MSBuild and exposing its output through the Razor SDK’s static web assets. The example also explains which dependency and generated-output folders belong outside source control.
An accompanying repository contains the complete project structure and build integration.