Awesome Open Source
Awesome Open Source


Go Report Card GoDoc

Web Push API Encryption with VAPID support.

go get -u


For a full example, refer to the code in the example directory.

package main

import (

	webpush ""

func main() {
	// Decode subscription
	s := &webpush.Subscription{}
	json.Unmarshal([]byte("<YOUR_SUBSCRIPTION>"), s)

	// Send Notification
	resp, err := webpush.SendNotification([]byte("Test"), s, &webpush.Options{
		Subscriber:      "[email protected]",
		TTL:             30,
	if err != nil {
		// TODO: Handle error
	defer resp.Body.Close()

Generating VAPID Keys

Use the helper method GenerateVAPIDKeys to generate the VAPID key pair.

privateKey, publicKey, err := webpush.GenerateVAPIDKeys()
if err != nil {
	// TODO: Handle error


  1. Install Go 1.11+
  2. go mod vendor
  3. go test

For other language implementations visit:

WebPush Libs

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
go (14,975