
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
svelte-useactions
Advanced tools
This library is based on the svelte-material-ui useActions implementation.
It enables you to use actions on custom components. Additionally you get type safety.
npm i svelte-useactions
#or
yarn add svelte-useactions
First create your component that accepts an array of actions.
<!-- Input.svelte -->
<script lang="ts">
import { useActions } from 'svelte-useactions';
import type { ActionList } from 'svelte-useactions';
export let use: ActionList<HTMLDivElement> = [];
</script>
<input use:useActions="{use}" />
Next define your action function
// autofocus.ts
export const autofocus: Action<HTMLInputElement> = (node) => {
node.focus();
};
Now you can define actions for components.
<!-- index.svelte -->
<script lang="ts">
import { autofocus } from '$lib/autosize';
import { createActionList } from 'svelte-useactions';
</script>
<input use={createActionList([[autofocus]])} />
You can also define parameters
// autofocus.ts
export const autofocus: Action<HTMLInputElement, string> = (node, text) => {
node.focus();
console.log(text);
};
<!-- Other code... -->
<Input use={createActionList([[autofocus, "hey!"]])} />
createActionList
is merely used for type-safety. If you don't care
about it you can just input a normal action list.
Example:
<!-- Other code... -->
<Input use={[[autofocus, "hey!"]]} />
useActions
Used in tandem with the use
directive. Accepts an action list as a parameter.
<script lang="ts">
import { useActions } from 'svelte-useactions';
import type { Actions } from 'svelte-useactions';
export let use: Actions<HTMLDivElement> = [];
</script>
<input use:useActions={use}
createActionList
A wrapper function that provides better intellisense/type-checking.
Takes in an action list
<!-- No parameters -->
<input use="{createActionList([[autofocus]])}" />
<!-- With parameters -->
<Input use={createActionList([[autofocus, "hey!"]])} />
<!-- Multiple Actions-->
<Input use={createActionList([[autofocus], [anotherAction, {foo: "bar"}]])} />
ActionList
An array of tuples where the first item is the action and optionally the parameters of the action as the second item.
let actions: ActionList<HTMLDivElement> = [];
const duration = 500;
// With one action
actions = [[autofocus]];
// One action with parameters
actions = [[longpress, duration]];
// Multiple actions
actions = [[longpress, duration], [autofocus]];
FAQs

The npm package svelte-useactions receives a total of 1 weekly downloads. As such, svelte-useactions popularity was classified as not popular.
We found that svelte-useactions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.