Templ Counter
HTML #
1<div data-init="@get('/examples/templ_counter/updates')">
2 <!-- Global Counter -->
3 <button
4 id="global"
5 class="info"
6 data-on:click="@patch('/examples/templ_counter/global')"
7 >
8 Global Clicks: 0
9 </button>
10
11 <!-- User Counter -->
12 <button
13 id="user"
14 class="success"
15 data-on:click="@patch('/examples/templ_counter/user')"
16 >
17 User Clicks: 0
18 </button>
19</div>Explanation #
This example demonstrates two counters - a global counter shared across all users and a user-specific counter. The counters are updated via server-sent events (SSE) and increment when clicked.