How to ssr Svelte and pass data from express in node js

Viewed 557

I am trying svelte and I might use it for my future website, but there is on thing that has stopped me from suing many js frameworks/compilers. It is server side rendering (one reason is I use server-less so it would be easier then prerendering). Is there a way to use express to server-side-render svelte on every request and also pass data from my node js app too so I don't have to make a bunch of other request? For example the App.svelte might be:

<script>
    export let data
    let count = 0
</script>

<main>
    <button on:click={count++}>Increase Count BY 1</button>
    <h1>{data}<h1>
</main>

and main.js:

import App from './App.svelte';

const app = new App({
    target: document.body,
    props: {
    
    }
});

export default app;

I want to get the data value from the server and use it in the svelte code and also sever-side-render it. Is there a way I can do this?

0 Answers
Related