Skip to main content

Overview

revolution/laravel-nostr is a package for using the Nostr protocol from Laravel. It provides key generation and conversion, event retrieval and publishing, pool (multi-relay) support, NIP-05 profiles, NIP-17 Private Direct Messages, and Laravel Notifications integration.
Because the Nostr specifications are still evolving, this package is under constant development. However, the notification features are already useful as-is.

Drivers

This package provides two drivers.
A unique feature of the native driver is the WebSocketHttpMixin implementation. It connects to WebSocket using Laravel’s HTTP client, and disconnects as soon as data is sent and received. You do not need to keep a WebSocket server running, making it accessible to any Laravel user.
The native driver does not support NIP-04.

Setting the default driver

Set the default driver in config/nostr.php or .env.
If you do not specify a driver, the default will be used.
You can also specify the driver explicitly.

Installation

1

Install the package

2

Publish the configuration file

Key management

Generate new keys

Convert keys

Convert from nsec:
Convert from secret key:
Convert from npub (public key only):
Convert from public key:

Getting events

Get multiple events

Get one event

Publishing events

Publish to a single relay

Publish to multiple relays (pool)

Relay server configuration

Which relay servers are used?

When using Nostr::event() alone, the first relay in config/nostr.php is used. When using Nostr::pool(), all relays in the configuration are used.

Change relay server at runtime

NIP-05 profile

NIP-17 Private Direct Messages

NIP-17 is only supported in the native driver.

Send a private direct message

Decrypt a received private direct message

Laravel Notifications

Use NostrChannel to send messages to Nostr through Laravel Notifications.

Notification class

On-demand notifications

User model integration

Relay servers for notifications

By default, all relays in config/nostr.php are used. Specify relays in NostrRoute to change them at runtime.
For the latest information, see the GitHub repository.
Last modified on April 29, 2026