Skip to content
This repository was archived by the owner on Jun 12, 2025. It is now read-only.

Commit 1a9333a

Browse files
committed
router prefetch
1 parent 8465ab2 commit 1a9333a

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

src/components/navigation/Navbar.tsx

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ export default function Navbar() {
5151
>
5252
<Container maxW='container.xl'>
5353
<Flex h={16} align='center' justify='space-between'>
54-
<Flex align='center' gap={2} cursor='pointer' onClick={() => router.push('/')}>
54+
<Flex
55+
align='center'
56+
gap={2}
57+
cursor='pointer'
58+
onMouseEnter={() => router.prefetch('/')}
59+
onClick={() => router.push('/')}
60+
>
5561
<Icon as={FiBook} boxSize={6} color='brand.primary.400' />
5662
<Text fontSize='xl' fontWeight='extrabold'>
5763
<Box as='span' color='brand.primary.400'>
@@ -63,7 +69,12 @@ export default function Navbar() {
6369

6470
<HStack spacing={4} display={{ base: 'none', md: 'flex' }}>
6571
{NAV_ITEMS.map((item) => (
66-
<Button key={item.label} variant='ghost' onClick={() => router.push(item.href)}>
72+
<Button
73+
key={item.label}
74+
variant='ghost'
75+
onMouseEnter={() => router.prefetch(item.href)}
76+
onClick={() => router.push(item.href)}
77+
>
6778
{item.label}
6879
</Button>
6980
))}
@@ -115,11 +126,23 @@ export default function Navbar() {
115126
<Box display={{ base: isMenuOpen ? 'block' : 'none', md: 'none' }} pb={4} bg='brand.dark.900'>
116127
<Stack spacing={4} px={4}>
117128
{NAV_ITEMS.map((item) => (
118-
<Button key={item.label} w='full' variant='ghost' onClick={() => router.push(item.href)}>
129+
<Button
130+
key={item.label}
131+
w='full'
132+
variant='ghost'
133+
onMouseEnter={() => router.prefetch(item.href)}
134+
onClick={() => router.push(item.href)}
135+
>
119136
{item.label}
120137
</Button>
121138
))}
122-
<Button w='full' leftIcon={<FiUser />} variant='outline' onClick={() => router.push('/profile')}>
139+
<Button
140+
w='full'
141+
leftIcon={<FiUser />}
142+
variant='outline'
143+
onMouseEnter={() => router.prefetch('/profile')}
144+
onClick={() => router.push('/profile')}
145+
>
123146
Mi Cuenta
124147
</Button>
125148
</Stack>

0 commit comments

Comments
 (0)