[!IMPORTANT]
vgrok is designed for quick local development. If you want quick production and preview deployments with secure public urls, connect your repo to Vercel so you can automatically deploy on git push.
CLI Usage
First, install globally from npm:
npm i -g @styfle/vgrok
Next, install vercel cli from npm and login and link to a project:
npm i -g vercelvercel loginvercel link
Don't want vercel cli?
If you don't want to install vercel cli, perhaps when disk space is constrained, you can set environment variables instead:
This is similar to linking a project so vgrok knows where to create the sandbox.
Finally, start the vgrok cli with the port of your local server, for example:
vgrok 3000
This will print a unique url so that your local server on port 3000, like next dev, is now accessible to the world.
The default behavior is to shutdown the connection and corresponding sandbox when the vgrok process exits (CTRL+C).
If you plan to run vgrok more frequently and don't want to wait a couple seconds for the sandbox, you can reuse a sandbox, or rather not shutdown the sandbox when the vgrok process exits.
vgrok 3000 start # create a sandbox and connect the tunnel# CTRL+C will disconnect the tunnel but not shudown the sandboxvgrok 3000 stop # shutdown the sandbox