svelte-link-interceptor
v0.1.2
Published
Svelte action to intercept all <a> tag clicks in your SPA — handle internal routing and external link modifications with ease.
Maintainers
Readme
svelte-link-interceptor
Svelte action to intercept all <a> tag clicks in your SPA. Handle internal routing and external link modifications with ease.
Install
npm install svelte-link-interceptorUsage
<script>
import { linkInterceptor } from 'svelte-link-interceptor'
const options = {
onInternalLink(ctx) {
ctx.preventDefault()
goto(ctx.path) // SvelteKit
},
onExternalLink(ctx) {
ctx.url.searchParams.set('utm_source', 'myapp')
},
}
</script>
<div use:linkInterceptor={options}>
...
</div>Docs & Playground
https://babu-ch.github.io/link-interceptor/?fw=svelte
