Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dlebedef's avatar

Inertia Link server side

Is it possible to generate "inertia-links" on the server side?

I'm working on a CMS and I would like the links inside the content (created by the user with a text field) of a page to act as inertia-links, hence load the page content without reloading the page.

Example:

<template>
	<div v-html="content"></div>
</template>
<script>
	export default {
		data() : {
			content: '<p>This is a paragraph...</p><inertia-link :href="/link-to-other-page">Link to other page</inertia-link>'
		}
	}
</script>

Wanted behaviour: if someone clicks on the link "Link to other page" we load the page dynamically.

Is there an existing or correct way to pass an html content to a vue template containing a link and making it so that when the html content is rendered and someone clicks on the link the page content is loaded dynamically without reloading the page?

Hope I made myself clear...

0 likes
9 replies
fylzero's avatar

@dlebedef Not possible. When you run Mix, inertia-link is compiled to something entirely different in JavaScript.

1 like
dlebedef's avatar

Actually I can store "<inertia-link></inertia-link>" on the database and then pass it as a template to a vue component and it gets compiled to a link.

So turns out this is possible. In case anyone is curious about the solution I can try to provide the elements needed to achieve this.

1 like
elOmega's avatar

@dlebedef Im having this exact issue and cant find a solution, could you provide the stepss to do so?

elOmega's avatar

@[aeo] Thanks for the fast reply but my problem is not about routing, my problem is that i need to change route without the page reloading entirely and i need to send the link from backend but i cant send an InertiaLink since it wont render

elOmega's avatar

@[aeo] thats the way im currently doing it but while using the a tag the page makes a full reload instead. In case it helps Im using the datatables.net library and i would like to send a link to edit the item of the list, but since that data is sent by the server the inertia-link is not being rendered. Im not sure partial reloads can help in this situation but i will take a look at it thanks!

dlebedef's avatar

@elOmega for info, the way I ended up doing this is by using Manual visits.

I listen for clicks on a elements in the DOM and depending on the href I then use Manual visits for internal links otherwise I use normal visits.

I don't know if there are better solutions, but I managed to make things work in my project for now.

Please or to participate in this conversation.