islands

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package islands provides JavaScript integration for Vango components.

Deprecated: The v1 Developer Guide exposes islands via `el.JSIsland`. This package is retained for legacy/internal use only.

Islands allow embedding third-party JavaScript libraries or custom client-side logic while maintaining the component lifecycle and server communication.

Usage (v1 canonical):

Div(
	JSIsland("my-chart", map[string]any{"data": [...] }),
)

By default the client loads `/js/islands/<id>.js` unless a `data-module` attribute is provided on the same element. Modules should export a mount(el, props, api) function that can optionally return {update, destroy, onMessage}.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeIslandPayload

func DecodeIslandPayload[T any](msg vango.IslandMessage) (T, error)

DecodeIslandPayload decodes an island message payload into a typed struct. This is useful for validation and to avoid relying on map[string]any.

Decoding is strict: unknown fields and trailing JSON values are rejected, matching vango.DecodeIslandPayload and IslandSchemaValidator behavior.

func IslandPlaceholder

func IslandPlaceholder(children ...any) *vdom.VNode

IslandPlaceholder renders a minimal SSR placeholder for island content. Use this inside the island container so the page is meaningful before JS mounts.

func JSIsland

func JSIsland(id string, props any) []vdom.Attr

JSIsland marks an element as an island boundary. The island name identifies which client module should mount. For custom module paths, set a data-module attribute on the same element.

func OnMessage added in v0.0.2

func OnMessage(handler func(vango.IslandMessage)) vdom.Attr

OnMessage registers a per-instance handler for messages emitted by this island boundary.

This attaches the handler to the island element itself (keyed by HID), so multiple islands with the same name can coexist on a page without conflicting message routing.

func SendToIsland

func SendToIsland(id string, payload any)

SendToIsland sends a message to the client-side island.

func SendToIslandHID added in v0.0.2

func SendToIslandHID(hid string, payload any)

SendToIslandHID sends a message to a specific island instance (addressed by HID).

func SetupOnIslandMessage

func SetupOnIslandMessage[P any](s *vango.SetupCtx[P], id string, handler func(vango.IslandMessage))

SetupOnIslandMessage registers a handler for messages from the island during Setup. This is the spec-aligned Setup-only variant.

func SetupOnIslandMessageValidated

func SetupOnIslandMessageValidated[P any](s *vango.SetupCtx[P], id string, validate IslandMessageValidator, handler func(vango.IslandMessage))

SetupOnIslandMessageValidated registers a handler with validation for island messages. If validation fails, the handler is not invoked and the error is logged.

Types

type IslandMessageValidator

type IslandMessageValidator func(vango.IslandMessage) error

IslandMessageValidator validates an incoming island message.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL