# Events
Event handlers and their naming conventions, template lifecycle, animating
removal, focus management, and flushing pending DOM updates.
Event handlers are `on`-prefixed attributes. Any TS expression that resolves to
a function works.
```ehtml Event handlers
```
### Event handlers run in the browser
An event handler, and every function it calls other than an `@rpc` function,
runs in the browser.
It cannot call `sql()`, `tx()`, `session.login()` or any other server-only
function. The compiler does not allow it: the build reports a security error at
the call site. To reach the database from a handler, call an `@rpc` function.
The RPC function runs on the server, and its code, including its queries, is
never sent to the browser.
```ehtml Calling the database from a handler
/** @rpc */
export function deleteMessage(id: string) {
session.isLoggedInOrThrow();
sql(`
delete from messages
where
id = ${id}
and authorId = ${session.getOrThrow("userId")}
`);
}
```
Writing `onclick={() => sql(...)}` instead is a compile error, not a shortcut.
### Typed parameters
Event handler parameters are typed per element and per event. Writing
`