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

SSR support examples #19

Closed
tonyrewin opened this issue Jul 10, 2021 · 1 comment
Closed

SSR support examples #19

tonyrewin opened this issue Jul 10, 2021 · 1 comment

Comments

@tonyrewin
Copy link

If there is any vision of how to do that - I'd like to know asap :)

@PaulMaly
Copy link
Member

PaulMaly commented Feb 16, 2023

I still don't have understandable example of SSR support, because it's very depends on you server-side implementation. But basic example on express could looks like:

require('svelte/register');
...
const App = require('./App.svelte').default;
...
app.get('*', (req, res) => {
  // run router hook
  require('svelte-pathfinder/ssr')();
  
  // navigate router to current server URL
  goto(req.url); 
  
  // render an App with current state
  res.render('index', App.render(/* some data */)); 
});

But I definitely advise everybody to use sveltekit if you need to take universal approach in your apps.

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

2 participants