Mar 13, 2025
0
Level 7
Inertia SSR not working
Hello,
I am trying to get my site to be SSR with laravel forge and D.O. I have configured my ssr.js:
import { renderToString } from '@vue/server-renderer';
import { createInertiaApp } from '@inertiajs/vue3';
import createServer from '@inertiajs/vue3/server';
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
import { ZiggyVue } from '../../vendor/tightenco/ziggy';
const appName = import.meta.env.VITE_APP_NAME || 'Laravel';
createServer((page) =>
createInertiaApp({
page,
render: renderToString,
title: (title) => `${title} - ${appName}`,
resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
setup({ App, props, plugin }) {
return createSSRApp({ render: () => h(App, props) })
.use(plugin)
.use(ZiggyVue, {
...page.props.ziggy,
location: new URL(page.props.ziggy.location),
});
},
})
);
and my app.js:
import './bootstrap';
import '../css/app.css';
import {createSSRApp, h} from 'vue';
import {createInertiaApp} from '@inertiajs/vue3';
import {resolvePageComponent} from 'laravel-vite-plugin/inertia-helpers';
import {ZiggyVue} from '../../vendor/tightenco/ziggy';
import {OhVueIcon, addIcons} from "oh-vue-icons";
import {FaFacebook, FaTwitter, FaInstagram, FaPhone} from "oh-vue-icons/icons";
import {createPinia} from 'pinia';
import * as FaIcons from "oh-vue-icons/icons/fa";
import posthogPlugin from "./plugins/posthog";
const Fa = Object.values({...FaIcons});
addIcons(FaFacebook, FaTwitter, FaInstagram, FaPhone)
addIcons(...Fa);
const appName = import.meta.env.VITE_APP_NAME || 'Laravel';
const pinia = createPinia();
import {register} from 'swiper/element/bundle';
register();
createInertiaApp({
title: (title) => `${title} - ${appName}`,
resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
setup({el, App, props, plugin}) {
return createSSRApp({render: () => h(App, props)})
.component("VIcon", OhVueIcon)
.use(plugin)
.use(pinia)
.use(posthogPlugin)
.use(ZiggyVue)
.mount(el);
},
progress: {
color: '#4B5563',
},
});
Also I have created a daemon for the ssr. When I view page source it doesn't seem to be using SSR. Please advise or let me know if you need any more information.
Thank you.
Please or to participate in this conversation.