Skip to content

Conversation

jrmajor
Copy link
Contributor

@jrmajor jrmajor commented Oct 11, 2024

Laravel part handled in inertiajs/inertia-laravel#673.

Adding support for SSR in dev mode would enable developers to discover hydration mismatches/errors before they reach production.

User would need to create additional entrypoint (alongside app.ts and ssr.ts):

import { createInertiaApp } from '@inertiajs/svelte'
import type { AppCallback } from '@inertiajs/svelte/server'

const render: AppCallback = (page) =>
  createInertiaApp({
    page,
    resolve: (name) => import(`./Pages/${name}.svelte`),
  })

export default render

...and add Inertia plugin to Vite:

  import { svelte } from '@sveltejs/vite-plugin-svelte'
  import laravel from 'laravel-vite-plugin'
  import { defineConfig } from 'vite'
+ import inertia from '@inertiajs/core/vite';

 export default defineConfig({
    plugins: [
      laravel({
        input: ['resources/css/app.css', 'resources/js/app.ts'],
        ssr: 'resources/js/ssr.ts',
        refresh: true,
      }),
+     inertia('resources/js/viteSsr.ts'),
      svelte(),
    ],
  })

@jrmajor jrmajor force-pushed the dev-ssr branch 3 times, most recently from 76bf077 to 4fdff4b Compare October 11, 2024 10:13
@harryqt
Copy link

harryqt commented Oct 11, 2024

This was indeed needed. 🚀

@anburocky3
Copy link

any update on this PR? Why isn't it merged? @jrmajor

@jrmajor
Copy link
Contributor Author

jrmajor commented Jun 6, 2025

@pascalbaljet I'll rebase this after #2276 is merged.

@pascalbaljet
Copy link
Member

@jrmajor This might be a long shot, but would it be possible to consolidate ssr.ts and viteSsr.ts somehow? I think it's already cumbersome that people have to maintain two main JS files with app.ts and ssr.ts, and it would be nice if we didn't have to introduce a third one.

@pascalbaljet pascalbaljet added the needs more info/work Needs more info from the author or additional work to get merged label Jun 17, 2025
@jrmajor
Copy link
Contributor Author

jrmajor commented Aug 16, 2025

would it be possible to consolidate ssr.ts and viteSsr.ts somehow?

I have an idea, changing to draft until I figure it out.

@jrmajor jrmajor marked this pull request as draft August 16, 2025 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info/work Needs more info from the author or additional work to get merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants