Skip to content

SolidJS

Install

bash
npm install alap solid-js

Setup

tsx
import { AlapProvider, AlapLink } from 'alap/solid';
import config from './alap-config';

function App() {
  return (
    <AlapProvider config={config}>
      <p>Check out <AlapLink query=".coffee">cafes</AlapLink>.</p>
    </AlapProvider>
  );
}

Components

Same Provider/Link/Hook pattern as React. SolidJS-specific differences:

  • Fine-grained signals — only the accessed fields trigger re-render
  • useAlap() returns signal-based accessors
  • Uses <Dynamic> component internally for menu rendering

<AlapProvider>

PropTypeDefaultDescription
configAlapConfigrequiredThe link configuration
menuTimeoutnumberfrom configAuto-dismiss timeout override
PropTypeDefaultDescription
querystringrequiredExpression to evaluate
childrenJSX.ElementrequiredTrigger content
anchorIdstringAnchor ID for bare @ macro
mode'dom' | 'webcomponent' | 'popover''dom'Rendering mode
menuClassNamestringCSS class on menu container
listType'ul' | 'ol'from configList element type
maxVisibleItemsnumberfrom configScroll after N items
onItemHover(detail) => voidMouse enters menu item
onItemContext(detail) => voidRight-click/ArrowRight on item

useAlap()

MethodSignatureDescription
query()(expression, anchorId?) => string[]Expression to item IDs
resolve()(expression, anchorId?) => Array<{ id } & AlapLink>Expression to link objects
getLinks()(ids) => Array<{ id } & AlapLink>IDs to link objects

Example

tsx
import { AlapProvider, AlapLink, useAlap } from 'alap/solid';
import config from './alap-config';

function CoffeeCount() {
  const { resolve } = useAlap();
  // Fine-grained: only re-renders when .coffee results change
  const count = () => resolve('.coffee').length;
  return <span>{count()} shops</span>;
}

function App() {
  return (
    <AlapProvider config={config}>
      <p>We know <CoffeeCount /> — <AlapLink query=".coffee">browse them</AlapLink>.</p>
    </AlapProvider>
  );
}