Link

Documentation and examples for the Link component.

When To Use

  • When you need to provide hyperlinks to other pages within your application or to external resources.
  • When you need a unified component that seamlessly handles type-safe internal routing (via astro-typesafe-routes) and standard external anchor tags.

Variants

Disabled Link

To visually disable a link, apply Tailwind utility classes like pointer-events-none and opacity-50 since standard HTML <a> elements do not natively support the disabled attribute.

When a link needs to look like a button (e.g., call-to-action links), apply button-equivalent Tailwind classes or import and apply the button variants directly to the <Link> component instead of nesting a <Button> inside it.

Example Usage

How to Use

The Link component provides a unified interface for both internal routing and external links. Internal links utilize astro-typesafe-routes to provide auto-completion and ensure routes exist. External links fall back to standard anchor tags.

Internal Links (Typesafe)

Use the to prop for internal navigation. This enables autocompletion for your defined routes.

External Links

Use the href prop for standard external URLs.

API

Property
Description
Type
Default

to

Internal route path for type-safe routing. any -

params

Route parameters for type-safe routing. Record<string, string> -

href

Standard external URL. string -