npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

vite-plugin-protobuf

v0.0.31

Published

Vite plugin that automatically compiles .proto files to TypeScript clients

Readme

vite-plugin-protobuf

A Vite plugin that compiles .proto files using protoc and @protobuf-ts to generate TypeScript clients, ready for use in your frontend app.

  • Powered by protobuf-ts
  • The plugin watches your .proto files and regenerates output on changes
  • All generated files are written to node_modules/.vite/proto-gen
  • You can access this output using the alias @proto-gen

Installation

Install the plugin:

npm install --save-dev vite-plugin-protobuf

Required Dependencies

You must manually add the following dependencies to your package.json:

{
  "dependencies": {
    "@protobuf-ts/runtime": "^2.9.6",
    "@protobuf-ts/runtime-rpc": "^2.9.6"
  },
  "devDependencies": {
    "@protobuf-ts/plugin": "^2.9.6",
    "@protobuf-ts/protoc": "^2.9.6",
  }
}

Then run:

npm install

Configuration

Add the plugin to your vite.config.ts or vite.config.js:

import protobuf from 'vite-plugin-protobuf';

export default {
  plugins: [
    protobuf({
      protoPath: '../proto'
    })
  ]
};

Usage with Vite + SPA (React, Vue, Svelte etc.)

Update your tsconfig.app.json (or equivalent) with the following path alias:

{
  "compilerOptions": {
    "paths": {
      "@proto-gen/*": [
        "./node_modules/.vite/proto-gen/*"
      ]
    }
  }
}

This ensures TypeScript can resolve the generated files.


Usage with SvelteKit

Modify the vite.config.ts like so:

import protobuf from 'vite-plugin-protobuf';

export default {
  plugins: [
    protobuf({
      protoPath: "../proto",
      outputDir: "./src/lib/proto",
    })
  ]
};

Once your .proto files are compiled, you can import the generated clients like so:

// Compiled from helloworld.proto
import { GreeterClient } from "$lib/proto/helloworld.client";

Next steps with gRPC Web

To use the generated clients with gRPC over HTTP in the browser, install:

npm install @protobuf-ts/grpcweb-transport

Then, create your gRPC client like this:

import { GreeterClient } from "@proto-gen/helloworld.client";
import { GrpcWebFetchTransport } from "@protobuf-ts/grpcweb-transport";

const transport = new GrpcWebFetchTransport({
  baseUrl: "https://your-grpc-api.com"
});

const client = new GreeterClient(transport);

async function greet() {
  const response = await client.sayHello({ name: "World" });
  console.log(response.response.message);
}

The GrpcWebFetchTransport provides a browser-friendly implementation of the gRPC-web protocol using standard fetch.

For more information, see protobuf-ts.