Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does SSR work with momentum-trail and svelte? #17

Open
simonsan opened this issue Sep 6, 2023 · 0 comments
Open

How does SSR work with momentum-trail and svelte? #17

simonsan opened this issue Sep 6, 2023 · 0 comments

Comments

@simonsan
Copy link

simonsan commented Sep 6, 2023

Server-side rendering

The SSR engine doesn't know the current URL you are requesting.

To make the method current work correctly on the initial page load, you must pass the initial URL to the options list.

createServer((page: Page) =>
  createInertiaApp({
    setup({ App, props, plugin }) {
      return createSSRApp({ render: () => h(App, props) })
        .use(trail, {
          routes,
          url: props.initialPage.url
        })
    },
  })
)

my current SSR.ts looks like this

import { createInertiaApp } from '@inertiajs/svelte';
import createServer from '@inertiajs/svelte/server';
import type { Page } from '@inertiajs/inertia';

createServer((page: Page) =>
	createInertiaApp({
		page,
		resolve: (name) => {
			const pages = import.meta.glob('./Pages/**/*.svelte', {
				eager: true
			});
			return pages[`./Pages/${name}.svelte`];
		}
	})
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant