1. Hello, Live
Lesson 1: Hello, Live
svelte-realtime lets you call server functions from your components as if they were local.
On the right you see two files:
src/live/greet.ts- a server function wrapped withlive()src/routes/+page.svelte- your component
The server file is already done. The greet function takes a name and returns a greeting. Your job is to call it from the component.
Try it
- Import
greetfrom'$live/greet' - Add a button that calls
greet('World')and setsmessageto the result
Since greet runs on the server, it's an async function - use await when calling it.
WebSocket
0
No messages yet