asChild and router links
Parts that render a link take asChild. With it, the part renders its only child instead of an a, and merges its classes and props onto it. Use it to render your router’s link:
import { Link as RouterLink } from 'react-router';
import { Link } from 'govuk-react/link';
<Link asChild>
<RouterLink to="/page">Page</RouterLink>
</Link>;
These parts take asChild:
LinkandBackLinkBreadcrumbs.LinkFooter.LinkNotificationBanner.LinkPagination.Link,Pagination.PreviousLink,Pagination.NextLink,Pagination.ItemLinkandPagination.ItemCompositeServiceNavigation.LinkSummaryList.ActionandSummaryList.ActionCompositeTaskList.Link
The behaviour primitives’ parts take asChild too, so you can render your own elements.
Buttons
Button and StartButton take as instead, because a link button is still a button: they keep their own content, such as the start button’s arrow, and add role="button" and draggable="false" to the link.
import { Link as RouterLink } from 'react-router';
import { Button } from 'govuk-react/button';
<Button as={RouterLink} to="/start">
Start now
</Button>;
Client-side routing
A router changes the page without the browser loading it, so the browser doesn’t move focus or announce the new page. Move focus to the new page’s heading or main content after navigating, and update the page title.