Link Parameter Utilities
Link parameters store a link to a project map node, a static URL, an email address, or a telephone number, plus an optional set of editor-set custom attributes (such as target, rel, class, or data-*). For how to configure a link parameter and how Uniform stores its value, see the Link parameter reference.
The SDK provides helpers that turn a stored link value into renderable attributes, so you don't have to derive the href or handle security concerns yourself.
Rendering a link value#
To render a link value, use linkParamValueToAnchorProps from @uniformdev/canvas-react (React) or linkParamValueToHtmlAttributes from @uniformdev/richtext (Vue, Nuxt, or any channel that produces HTML strings). Both helpers derive the href (including the mailto:/tel: prefix and any anchor), spread the editor-set attributes, and apply the built-in safeguards described below. All link types (project map nodes, static URLs, email addresses, and telephone numbers) are handled for you.
When the link is a project map node, the value stays valid even if the node is later moved elsewhere in the project map, and you can read the nodeId, dynamicInputValues, and projectMapId from the value.
The following InternalLink component renders any link type with the framework's native link component (Next.js Link or NuxtLink):
/src/components/InternalLink.tsx
/components/InternalLink.vue
note
For plain React, spread the result directly onto an <a> element: <a {...linkParamValueToAnchorProps(link)}>{label}</a>.
Built-in safeguards#
The helpers apply two behaviors automatically:
target="_blank"getsrel="noopener noreferrer"added, unless the editor setrelexplicitly.- The dangerous attributes (
href,src,style,formaction, or anyon*handler such asonclick) are dropped silently, as are attribute values with ajavascript:scheme. Thehrefis always derived from the link value, never from an attribute.
In React output, a class attribute is translated to className.
Import reference#
| Export | Package | Description |
|---|---|---|
linkParamValueToAnchorProps | @uniformdev/canvas-react | Convert a link value to React anchor props (class becomes className) |
linkParamValueToHtmlAttributes | @uniformdev/richtext | Convert a link value to a sanitized HTML attribute record (href plus custom link attributes) |
linkParamValueToHref | @uniformdev/richtext | Convert a link value to a href string (adds the mailto:/tel: prefix for email and telephone links) |