https://github.com/iamelevich/pocketbase-plugin-ngrok
Plugin for Pocketbase that allow you expose it with ngrok
https://github.com/iamelevich/pocketbase-plugin-ngrok
ngrok pocketbase pocketbase-plugins
Last synced: 6 days ago
JSON representation
Plugin for Pocketbase that allow you expose it with ngrok
- Host: GitHub
- URL: https://github.com/iamelevich/pocketbase-plugin-ngrok
- Owner: iamelevich
- License: mit
- Created: 2023-03-19T20:04:42.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2026-04-07T21:49:56.000Z (2 months ago)
- Last Synced: 2026-04-07T23:24:35.189Z (2 months ago)
- Topics: ngrok, pocketbase, pocketbase-plugins
- Language: Go
- Homepage:
- Size: 546 KB
- Stars: 11
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-pocketbase - GitHub
- awesome-pocketbase - Ngrok - Expose local PocketBase to the internet with ngrok.  (Go Plugins)
README
[](https://github.com/iamelevich/pocketbase-plugin-ngrok/actions/workflows/test.yml)
[](https://codecov.io/github/iamelevich/pocketbase-plugin-ngrok)
* [Overview](#overview)
* [Requirements](#requirements)
* [Installation](#installation)
* [Example](#example)
* [pocketbase\_plugin\_ngrok](#pocketbasepluginngrok)
* [Index](#index)
* [type Options](#type-options)
* [type Plugin](#type-plugin)
* [func MustRegister](#func-mustregister)
* [func Register](#func-register)
* [func \(\*Plugin\) Validate](#func-plugin-validate)
* [Contributing](#contributing)
* [Process](#process)
* [Development setup](#development-setup)
* [Testing](#testing)
* [Linting](#linting)
* [Docs update in README](#docs-update-in-readme)
# Overview
This plugin allow expose local [Pocketbase](https://github.com/pocketbase/pocketbase) with [ngrok](https://ngrok.com/)
This plugin can be used for development purposes, when you need to expose your local Pocketbase instance to the internet. For example, you can use it to test your Pocketbase app on mobile device.
## Requirements
- Go 1.25+
- [Pocketbase](https://github.com/pocketbase/pocketbase) 0.36+
## Installation
```bash
go get github.com/iamelevich/pocketbase-plugin-ngrok
```
## Example
You can check examples in [examples folder](/examples)
```go
package main
import (
"context"
ngrokPlugin "github.com/iamelevich/pocketbase-plugin-ngrok"
"log"
"github.com/pocketbase/pocketbase"
)
func main() {
app := pocketbase.New()
// Setup ngrok
ngrokPlugin.MustRegister(app, &ngrokPlugin.Options{
Ctx: context.Background(),
Enabled: true,
AuthToken: "YOUR_NGROK_AUTH_TOKEN", // Better to use ENV variable for that
})
if err := app.Start(); err != nil {
log.Fatal(err)
}
}
```
# pocketbase\_plugin\_ngrok
```go
import "github.com/iamelevich/pocketbase-plugin-ngrok"
```
## Index
- [type Options](<#Options>)
- [type Plugin](<#Plugin>)
- [func MustRegister\(app core.App, options \*Options\) \*Plugin](<#MustRegister>)
- [func Register\(app core.App, options \*Options\) \(\*Plugin, error\)](<#Register>)
- [func \(p \*Plugin\) Validate\(\) error](<#Plugin.Validate>)
- [type TunnelForwarder](<#TunnelForwarder>)
Options defines optional struct to customize the default plugin behavior.
```go
type Options struct {
// Ctx is a context that will be used to start ngrok tunnel.
Ctx context.Context
// Enabled defines if ngrok tunnel should be started.
Enabled bool
// Enable logging of ngrok events to pocketbase logger
EnableLogging bool
// AuthToken is your ngrok auth token. You can get it from https://dashboard.ngrok.com/auth
AuthToken string
// AfterSetup is a callback function that will be called after ngrok tunnel is started.
AfterSetup func(url *url.URL) error
// TunnelForwarder is optional. When set, used instead of ngrok for creating tunnels.
// Primarily useful for testing without a real ngrok connection.
TunnelForwarder TunnelForwarder
}
```
```go
type Plugin struct {
// contains filtered or unexported fields
}
```
```go
func MustRegister(app core.App, options *Options) *Plugin
```
MustRegister is a helper function that registers plugin and panics if error occurred.
```go
func Register(app core.App, options *Options) (*Plugin, error)
```
Register registers plugin.
### func \(\*Plugin\) [Validate]()
```go
func (p *Plugin) Validate() error
```
Validate plugin options. Return error if some option is invalid.
TunnelForwarder creates ngrok tunnels. Used for dependency injection in tests. When nil, the default ngrok implementation is used.
```go
type TunnelForwarder interface {
Forward(ctx context.Context, upstreamAddr, authToken string, enableLogging bool, logger interface{}) (*url.URL, error)
}
```
Generated by [gomarkdoc]()
# Contributing
This pocketbase plugin is free and open source project licensed under the [MIT License](LICENSE.md).
You are free to do whatever you want with it, even offering it as a paid service.
## Process
- Fork the repo
- Create a new branch
- Make your changes
- Create a pull request
- Wait for review
- Make changes if needed
- Merge
- Celebrate :)
## Development setup
- Install [mise](https://mise.jdx.dev/installing-mise.html) and run `mise install`.
- Setup `prek` hooks with `prek install -t commit-msg -t pre-commit`
## Testing
- Run `mise run test` to run tests
- Run `mise run test-report` to run tests and get coverage report in `./coverage.html`
## Linting
- Run `mise run lint` to run linters
## Docs update in README
- Run `mise run docs` to update docs in README (it will also install [gomarkdoc](https://github.com/princjef/gomarkdoc))