Skip to content

How to use router-link and exactActiveClass inside islands? #112

Answered by ElMassimo
mseele asked this question in Q&A
Discussion options

You must be logged in to vote

@mseele Since vue-router would not be available in the production bundle, a workaround is to pass router-link to islands using slots:

<template>
  <ExampleIsland :data="data" client:load>
    <router-link to="/" exactActiveClass="text-red-500">Home</router-link>
  </ExampleIsland>
</template>

Have in mind that the content passed to islands using slots will be pre-rendered at build time as static HTML (no JS to hydrate it or re-render it), but in most cases that should be enough. You can also used named slots if needed.

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@ElMassimo
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by ElMassimo
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #110 on March 28, 2022 20:21.