Link() function
Home > @rimitive/router > Link
Link() function
Section titled “Link() function”Link builder function
Link is inherently DOM-coupled (uses window.history, MouseEvent, href, onclick). Routers are web browser concepts - no need for adapter abstraction here.
Signature:
export declare function Link(props: ElementProps<DOMAdapterConfig, 'a'> & { href: string;}): (...children: ElRefSpecChild[]) => RefSpec<HTMLAnchorElement>;Parameters
Section titled “Parameters”|
Parameter |
Type |
Description |
|---|---|---|
|
props |
ElementProps<DOMAdapterConfig, ‘a’> & { href: string; } |
Returns:
(…children: ElRefSpecChild[]) => RefSpec<HTMLAnchorElement>
Example
Section titled “Example”import { Link } from '@rimitive/router';
// Basic linkconst navLink = Link({ href: '/about' })('About Us');
// Link with propsconst styledLink = Link({ href: '/products', class: 'nav-link', onclick: (e) => console.log('clicked')})('Products');
// Dynamic navigationconst productId = signal('123');const dynamicLink = Link({ href: computed(() => `/products/${productId()}`)})('View Product');