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 ¶
- func DecodeIslandPayload[T any](msg vango.IslandMessage) (T, error)
- func IslandPlaceholder(children ...any) *vdom.VNode
- func JSIsland(id string, props any) []vdom.Attr
- func SendToIsland(id string, payload any)
- func SetupOnIslandMessage[P any](s *vango.SetupCtx[P], id string, handler func(vango.IslandMessage))
- func SetupOnIslandMessageValidated[P any](s *vango.SetupCtx[P], id string, validate IslandMessageValidator, ...)
- type IslandMessageValidator
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.
func IslandPlaceholder ¶
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 ¶
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 SendToIsland ¶
SendToIsland sends a message to the client-side island.
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.