Skip to content

Conversation

@innocenzi
Copy link
Contributor

@innocenzi innocenzi commented Jan 12, 2026

This pull request adds support for passing a function as the value of the router option. When specified, this function will be passed as the navigate prop of BaseLink.

This enables the ability for any front-end framework to provide their own routing logic in a better way than intercepting all <a> clicks on the DOM.

For instance, to add Hybridly support, the following options can be passed to the Vite plugin:

import { router } from 'hybridly'

//...

vue.use(ui, {
	router: (event: MouseEvent, { href, external }: { href: string; external: boolean }) => {
		const target = event.currentTarget as HTMLElement
		const method = target.dataset.method as Method || 'GET'

		if (external) {
			return
		}

		event.preventDefault()

		router.navigate({
			url: href,
			method,
			preserveState: method !== 'GET',
		})
	},
})

Theoretically, the Inertia implementation could be migrated to use this pattern too instead of swapping components entirely.

@github-actions github-actions bot added the v4 #4488 label Jan 12, 2026
@innocenzi innocenzi force-pushed the feat/fn-based-routing branch from 5ee6d2a to 7f44f2e Compare January 12, 2026 22:09
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 12, 2026

npm i https://pkg.pr.new/@nuxt/ui@5860

commit: bd74317

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v4 #4488

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant