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 🙏

© 2024 – Pkg Stats / Ryan Hefner

vite-plugin-ngrok

v1.0.0

Published

A Vite plugin for seamless integration with ngrok, allowing you to easily share your local development server with anyone, anywhere.

Downloads

8,918

Readme

Vite Plugin ngrok 🎉

A vite plugin to automatically create a ngrok tunnel during local dev. This plugin uses the @ngrok/ngrok Javascript SDK

Features

  • Ngrok Integration: Quickly expose your Vite development server to the internet using Ngrok tunnels.
  • Dynamic URLs: Automatically updates Ngrok URLs when your local server restarts or when the Ngrok tunnel is reopened.
  • Custom Configuration: Fine-tune Ngrok options through a simple configuration file.
  • Simple Sharing: Just install the plugin, add your auth token, and start sharing your project.

How to use

  1. Create a Vite project

  2. Install the plugin into your project

npm i -D vite-plugin-ngrok
  1. Create / Configure a vite.config.ts file in your project root.
import { loadEnv, defineConfig } from 'vite'
import { ngrok } from 'vite-plugin-ngrok'

export default defineConfig({
  // Note you should not store your ngrok token in your code/repo. Make sure to move this to 
  // a more secure place before sharing your project.
  plugins: [
    ngrok('NGROK_AUTH_TOKEN_IN_HERE'),
  ],
})
  1. Fire up Vite as usual
npm run dev

Configuration

The ngrok plugin can be configured in 3 ways.

  1. No configuration. This will default to automatically use the vite port and authtoken_from_env will be set to true. This will look for NGROK_AUTHTOKEN in your environmental variables.
ngrok()
  1. If given a string the plugin will assume this is your auth token and configure it automatically with the vite port.
ngrok('NGROK_AUTH_TOKEN_IN_HERE'),
  1. Full ngrok config. If given an object you can pass in any options from the ngrok config. This will be merged with the default port from vite so that does not need to be set. Config properties can be found in the ngrok Javascript SDK Config docs
ngrok({
  domain: 'my-domain',
  compression: true
  authtoken: 'NGROK_AUTH_TOKEN_IN_HERE',
  ...
})

Advanced

You can use Vite's built in env parsing to store your ngrok token in a local file and ignore it from git.

import { loadEnv, defineConfig } from 'vite'
import { ngrok } from 'vite-plugin-ngrok'
const { NGROK_AUTH_TOKEN } = loadEnv('', process.cwd(), 'NGROK')

export default defineConfig({
  plugins: [
    ngrok({
      authtoken: NGROK_AUTH_TOKEN,
    }),
  ],
})