Actions
Actions

Overview

A package for working with server actions in React (new tab).

npm versionnpm downloadsBundlephobia

Installation

Required dependencies

This package relies on React hooks (new tab) and thus requires version 16.3 or higher.

# npm
npm i --save @weser/actions

# yarn
yarn add @weser/actions

# pnpm
pnpm add @weser/actions

Motivation

Using server actions (new tab) in React is a great way to handle server-side logic in a type-safe way.
But there's no straightforward way to handle things like loading states and errors. This requires quite some boilerplate that I wanted to reduce with this package.

Benefits

This package provides a simple hook that handles the loading states and errors for you.
It also provides a standard format for action responses so that every action follows the same pattern.

On this page