Skip to main content

Link

With Link you can render a link-type field from the content schema. It renders an HTML a tag and supports client-side relative navigation.

Usage

import { Link } from "@instantcommerce/sdk";

const BlockComponent = () => {
const { content } = useBlockState();

return <div>{!!content.link && <Link to={content.link}>My link</Link>}</div>;
};

export default defineBlock({
component: BlockComponent,
contentSchema: {
fields: {
link: { type: "link" },
},
},
});

Typing

interface LinkProps extends HTMLProps<HTMLAnchorElement> {
children: ReactNode;
to: any;
}