JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 21
  • Score
    100M100P100Q80729F
  • License MIT

Build Amorish widgets — Lovable apps that embed inside other Lovable apps via a secure postMessage bridge.

Package Exports

  • @amorish/widget

Readme

@amorish/widget

Build Amorish widgets — Lovable apps that embed inside other Lovable apps via a secure postMessage bridge.

Install

npm i @amorish/widget @amorish/protocol zod

Usage

In your widget app's embed entrypoint:

import { AmorishProvider, useAmorish } from "@amorish/widget";

function ReviewsWidget() {
  const { theme, user, request, emit, ready } = useAmorish();

  if (!ready) return <div>Loading…</div>;

  const loadProducts = async () => {
    const products = await request<unknown, Array<{ id: string; name: string }>>(
      "products.list",
    );
    console.log(products);
  };

  return (
    <div style={{ background: theme.colors.background, color: theme.colors.foreground }}>
      <p>Hi {user?.name ?? "guest"}</p>
      <button onClick={loadProducts}>Load products from host</button>
      <button onClick={() => emit("review.created", { rating: 5 })}>
        Submit review
      </button>
    </div>
  );
}

export default function App() {
  return (
    <AmorishProvider widgetVersion="1.0.0">
      <ReviewsWidget />
    </AmorishProvider>
  );
}

See the full guide at https://amorish.dev/docs/widget.