Hotwire
Small helpers for working with Hotwire Turbo streams.
Response.turboStream
Marks an existing response as a Turbo Stream by replacing its Content-Type with
text/vnd.turbo-stream.html.
- Example
- Declaration
renderTemplate(request, "items/_row", model).turboStream()
fun Response.turboStream(): Response
turboStreamRefresh
Returns a Turbo Stream response with a <turbo-stream action="refresh"> body, used to ask the client
to perform a full page refresh.
- Declaration
fun turboStreamRefresh(): Response
turboStreamRedirect
Returns a Turbo Stream response with a <turbo-stream action="redirect"> body, used to navigate the
browser to another page. Turbo swaps the body of a stream response into the current page rather than
following a redirect, so a handler answering a Turbo form submission sends this instead of a 303 when the
next thing the user should see is another page.
- Example
- Declaration
turboStreamRedirect("/items/${item.id}")
fun turboStreamRedirect(url: String): Response