TypeScript SDK and the link-preview element
The repository contains a dependency-free TypeScript client and a <link-preview> custom element. Both live in packages/sdk.
The @omnillink/sdk package is built from the repository. Its publication on the npm registry is not confirmed at this time: until then, install it from packages/sdk.
The client
import { createClient } from '@omnillink/sdk';
const omnillink = createClient({ baseUrl: 'https://omnillink.kayzen-lyon.com' });
const { data, meta } = await omnillink.meta('https://example.com/blog/launch');
console.log(data.title, data.image?.url, meta.cached);
| Option | Default | Purpose |
|---|---|---|
baseUrl | Default– | PurposeOrigin of the instance. /api/v1 is appended for you. |
apiKey | Default– | PurposeSent in the x-api-key header. |
fetch | Defaultglobal fetch | PurposeYour own implementation, for tests for instance. |
timeoutMs | Default30000 | PurposeTime allowed for a whole request. 0 disables it. |
The meta, extract, content, screenshot and pdf methods take the parameters of the API. The JSON methods resolve to { data, meta }.
The <link-preview> element
A separate entry point registers the element. It renders a preview card from /meta.
<script type="module">
import '@omnillink/sdk/element';
</script>
<link-preview url="https://example.com/blog/launch" base-url="https://omnillink.kayzen-lyon.com"></link-preview>
React
The @omnillink/react package, in packages/react, provides the <LinkPreview> component and the useLinkMeta() hook. The component wraps the <link-preview> element with typed props. On the server it renders a plain link; in the browser it becomes the card.
import { LinkPreview } from '@omnillink/react';
<LinkPreview url="https://example.com/blog/launch" baseUrl="https://omnillink.kayzen-lyon.com" />;
GitHub Action
The .github/actions/link-preview action fetches the metadata of an address, exposes it as step outputs and writes a preview to the job summary. It can also take a screenshot.
- uses: kayzen-lyon/linkforge/.github/actions/link-preview@main
id: preview
with:
url: https://example.com/blog/launch
base-url: https://omnillink.kayzen-lyon.com
- run: echo "$TITLE"
env:
TITLE: ${{ steps.preview.outputs.title }}
The playground generates this tag for the address you are testing. The options are detailed in the README.md of the package.