Adds a reusable link field to Payload collections, with a Lexical editor feature that shares the same value shape. A plugin resolves internal document URLs through a configurable callback. It includes admin styles, HTML converters and React JSX converters for frontend rendering. Targets Payload 4.
PayloadCMS link-field plugin.
Installation
npm i @sittari/payload-link-field0
Stars
0
Forks
0
Open Issues
1 months ago
Last Updated
0
Weekly Downloads
v0.4.1
npm Version
197.3 KB
Unpacked Size
1
Dependencies
Trends appear after 7 days of data. Daily snapshots have not started yet.
Shared by 8 plugins in sittari-studio/payload-plugins.
Trends appear after 7 days of data. Daily snapshots have not started yet.
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1294311885-link-field)<a href="https://payloaddirectory.dev/plugins/1294311885-link-field"><img src="https://payloaddirectory.dev/badge/1294311885-link-field.svg" alt="Payload Directory"></a>README
PayloadCMS link-field plugin.
pnpm add @sittari/payload-link-field
Import the admin stylesheet from your Payload admin CSS file:
@import '@sittari/payload-link-field/admin.css';
import { buildConfig } from 'payload';
import { linkField, linkFieldPlugin } from '@sittari/payload-link-field';
export default buildConfig({
plugins: [
linkFieldPlugin({
resolveDocumentUrl: ({ collectionSlug, document }) => {
if (collectionSlug === 'pages' && typeof document?.slug === 'string') {
return `/${document.slug}`;
}
return null;
},
}),
],
collections: [
{
slug: 'pages',
fields: [
{
name: 'title',
type: 'text',
},
linkField({
name: 'link',
label: 'Link',
appearance: 'drawer',
relationTo: ['pages', 'posts'],
localizeLabel: true,
}),
],
},
],
});
localizeLabel controls whether the link's nested label field is localized.
It defaults to true; set it to false when link labels should use one value
across all locales.
LinkFieldFeature() uses the same field schema and value shape as linkField(). It must
replace Payload's native feature (both features use the link key), and
linkFieldPlugin() remains required because it registers resolveDocumentUrl for reads
and serialization.
import { lexicalEditor } from '@payloadcms/richtext-lexical';
import { LinkFieldFeature } from '@sittari/payload-link-field';
const editor = lexicalEditor({
features: ({ defaultFeatures }) => [
...defaultFeatures.filter((feature) => feature.key !== 'link'),
LinkFieldFeature({
relationTo: ['pages', 'posts'],
}),
],
});
The feature accepts defaultType, relationTo, showLabel, and showNewTab.
When relationTo is omitted, all non-internal collections are considered and
collections the current admin user cannot read are removed from the relationship
selector. Collections whose slugs start with payload- are always discarded,
including when explicitly provided.
Existing Payload-native custom and internal link nodes are normalized lazily when read or
opened in the editor; their next save writes only the plugin-owned field shape.
Payload v4 HTML conversion requires custom node converters to be passed explicitly:
import {
convertLexicalToHTMLAsync,
defaultHTMLConvertersAsync,
} from '@payloadcms/richtext-lexical/html-async';
import { LinkFieldHTMLConverters } from '@sittari/payload-link-field';
const html = await convertLexicalToHTMLAsync({
converters: {
...defaultHTMLConvertersAsync,
...LinkFieldHTMLConverters,
},
data,
});
The React export provides JSX converters for Payload's RichText component and is safe to
import from React Server Components. Spread the plugin converters after Payload's defaults:
import { RichText } from '@payloadcms/richtext-lexical/react';
import { LinkFieldJSXConverter } from '@sittari/payload-link-field/react';
export const Content = ({ data }) => (
<RichText
converters={({ defaultConverters }) => ({
...defaultConverters,
...LinkFieldJSXConverter(),
})}
data={data}
/>
);
The spread order intentionally replaces Payload's default link and autolink converters.
The converter renders only a populated fields.url; unresolved links preserve their
formatted children without rendering an anchor or falling back to customUrl.
Pass a renderer to integrate Next.js Link, analytics, or custom routing. The renderer
receives normalized fields, rendered children, url, newTab, and the untouched
serialized node:
import Link from 'next/link';
import { LinkFieldJSXConverter } from '@sittari/payload-link-field/react';
const converters = LinkFieldJSXConverter({
renderer: ({ children, newTab, url }) => (
<Link
href={url}
rel={newTab ? 'noopener noreferrer' : undefined}
target={newTab ? '_blank' : undefined}
>
{children}
</Link>
),
});
payload plugin json form builder
Turn a Payload JSON field into real admin fields with an in-admin form builder
580/wk29v3
heading field
Field wrapper that lets editors choose the h1–h6 tag for text, textarea, or rich text headings
540/wk15v3
payload plugin reading time
Computed reading time and word count fields for Payload Lexical rich-text content
410/wk1v3
richtext
Rich-text child block, default Lexical editor preset and JSX renderer for Atomic Payload
610/wk37v3
plugin
On-page editing and draft preview links for Payload collections and globals on a Next.js frontend
610/wk0v3 v4
payload lexical typography
Lexical editor features for text color, font size, letter spacing, line height and font family
571.1k/wk109v?