Would it be a better idea to use JavaScript, or r...
# ktor
h
Would it be a better idea to use JavaScript, or route a user to some page, and then reroute them to another page and add some args, etc to update the page? Speed doesn't matter
d
What are you trying to do? Why two redirections? In JS you can refresh the page too:
<script>location.reload();</script>
h
I don't want to only refresh. When it refreshes, I want it to change / add info to the page
And I don't want to use JS. That language is đź’©
m
If you want to dynamically update stuff in the page, you need code running in the browser at some point. You don't have to write JS, though. You can use a language that transpiles, like TypeScript or Elm, or something that emits WebAssembly.
h
gotcha
how would i use typescript or elm with ktor tho? got any examaples, etc?
m
I have a project currently that uses TS but unfortunately it's closed source or I'd link you to it. The general idea is to use ktor to serve data (typically JSON) and to construct the UI on the client side. I'm using TypeScript with React, which is a common combo. It's not the One True Solution (nothing is) but it's productive and pretty simple to get going with.
Alternately you could render most things on the server as HTML elements the traditional way, and add a limited amount of TypeScript/JS/whatever that maybe makes a few ajax calls or other limited interactivity.
If you want to make a typescript + react app, I suggest starting with https://github.com/wmonk/create-react-app-typescript
h
but that doesn’t use ktor
i need ktor
because i need to do some server side stuff with kotlin
m
That's just the front end.
Use ktor for the backend.
d
You can also use kotlin-js, I have created a sample showing how to mix ktor, kotlin-js and shared code here: https://github.com/ktorio/ktor-samples/tree/master/other/fullstack-mpp