Also known as the use
directive, and are element-level lifecycle functions.
Svelte Actions are not to be confused with Server actions in SvelteKit
Using an action this way, we can get access to the element in Svelte, as we would be operating in the DOM normally.
function actionName(node) {
node.addEventListener('click', () => {
alert('Hello World')
})
node.textContent = 'Hello World'
}
// our element:
<h2 use:actionName>my element</h2>