Start now →

ADVANCED ZUSTAND “3”. Middleware Internals & Writing Custom Middleware

By Simuratli · Published February 27, 2026 · 1 min read · Source: Level Up Coding
Blockchain
ADVANCED ZUSTAND “3”. Middleware Internals & Writing Custom Middleware

Member-only story

ADVANCED ZUSTAND “3”. Middleware Internals & Writing Custom Middleware

SimuratliSimuratli3 min read·1 day ago

--

Press enter or click to view image in full size

Zustand middlewares are used to extend, intercept, or manipulate store behaviour. Let’s think with a small example:

Middleware in Zustand generally wraps store creators as Higher Order Functions (HOC).

In easy way we can think like: If we don’t have middleware:

Component  →  Store → State

If we have middleware:

Component → Store → Middleware → State
import { create } from 'zustand';
import { devtools } from 'zustand/middleware';

const useStore = create(
devtools((set) => ({
count: 0,
increment: () => set((state) => ({ count: state.count + 1 })),
}))
);

In here, devtools is middleware, and it intercept set/get process of the store and sends it to Devtools (Redux devtools).

Middleware Internals

The basic working principle of Zustand middleware is as follows:

  1. The store is wrapped during creation.
  2. The set and get Functions can be…
This article was originally published on Level Up Coding and is republished here under RSS syndication for informational purposes. All rights and intellectual property remain with the original author. If you are the author and wish to have this article removed, please contact us at [email protected].

NexaPay — Accept Card Payments, Receive Crypto

No KYC · Instant Settlement · Visa, Mastercard, Apple Pay, Google Pay

Get Started →