Very often when you are building SPA you need to make sidebar with some menu.
And you need to show active class when the page is current.
I had the similar situation in InertiaJs package. InertiaJs has helper for current route.
Code example:
<SidebarLink
label="Daily sessions"
route={route('analytics.daily-sessions')}
active={route().current('analytics.daily-sessions')}
/>
import { Link } from '@inertiajs/react';
const SidebarLink = (props) => {
const { route, label, active } = props;
return (
<Link
className={" hover:bg-graydark " + (active ? 'bg-graydark dark:bg-meta-4' : '')}
href={route}
</Link>
export default SidebarLink;