Hi, I'm webdev noob. I understand that in a pure ...
# kobweb
u
Hi, I'm webdev noob. I understand that in a pure react/compose-html app the html that will be deployed is basically just a shell and js will generate the rest of the DOM on client side and there is SSR which will precalculate the whole DOM, send that and browser just renders it as well Then there is kobweb export. Am I correct in saying that it's trying to be something in the middle? If so, how does it achieve that? When the site is rendered (so the included js is run) with a headless browser, and say i have there js which will hit an api, how would the kobweb export know to not bake the response in? Is it even trying to discriminate the static and dynamic stuff?
s
for fine grained control about exporting you can use the isExporting property https://kobweb.varabyte.com/docs/concepts/foundation/exporting#pagecontext-isexporting
u
so by defaukr it wont know / cant know, and will bake in the api results, right?
s
yes
u
I see makes sense, thanks!
r
SSR is generally a more complicated concept. You can use this term to describe apps that run fully on the server and render mostly plain HTML (old school PHP, JSP, JSF or more modern HTMX). But the term is also used to describe apps, that are working mostly in the browser, but the HTML sent to the browser is also rendered on the server for better SEO and user experience (e.g. React + Next.js).
👍 1
u
and kobweb export is then what?
s
static site generation SSG
u
okay yea a 3rd thing
r
Yep. It's not SSR.
u
okay cool, I was only so far aware of csr and ssr, thanks!
r
If you would like SSR with Kotlin, also supporting dynamic API calls you described, you can try #C06UAH52PA7 (disclaimer: I'm the author so sorry for small advertising 🙂)
🤝 1
👍 1
s
yeah kobweb will not work for "full" SSR. you can use some templating for pure SEO purposes but generally SSG is happening at compile time
u
Hm but say i already have a ktor backedn and like it should I have another server that does the ssg and queries ktor or try to stuff the ssg into ktor
s
no SSG happens during the export process = at compile time. you can generate code at build time (https://kobweb.varabyte.com/docs/guides/generating-code) that queries your backend but that's only suitable for data that's not changing too often and too quickly, since for every new dataset you need to compile and export again
u
yea sorry I got it mixed up with ssr makes sense thanks
👍🏻 1
Also, SSR the motivation is performance or seo or both? If seo then I understand, if im medium.com and I want the articles indexed but I see performance sometimes quoted is that really the case? I mean then it eats my server cpu time for which I pay for. The paypload is bigger, decompression needs to do more etc, so am I really saving client cpu?
r
It's most about client-side perfromance
s
I'm not sure if performance is so much of a concern anymore, mostly indexing dynamic content. However, Google also runs a sites js, and I found it to index kobweb sites with dynamic content without SSR just fine
AI crawlers do not run any js though, if that's of importance
r
With SSR the page is visible as soon as it's downloaded, the user doesn't need to wait until JS is executed and the whole HTML is generated.
u
yea but payload is bigger so that wait is longer (?)
s
but you don't need two roundtrips
u
well yea, but say its a react app which does no requesrs, just builds the dom
but I think I'm getting the gist of it, thanks
anyways, if there is no dynamic content, like in portfolio website then ssg and ssr are effectively identical, right? or even ssg actually being faster, right?
s
SSG is definitely less resource demanding in that case. and the first time to render is the same, since the user is served the pre rendered page, yeah
r
And of course you can have dynamic content even with SSG, just not rendered / pre-rendered on the server. The downloaded app is still fully functional kobweb app, which can call any APIs and generate any additional content.
s
yes and Google might index it as well, whether you want or not, so it's a good idea to monitor your site with google search console
😄 1
u
thank yous