/handbook/developing-for-block-editor-and-site-editor/state-management-in-gutenberg/
What We Do
Digital Platform MigrationsKey SolutionsManaged ServicesStaffing SolutionsIndustriesProducts
OnePress
Unify multiple brands on one governed WordPress platform.
Design & UI/UX
Gutenberg-native UX, UI, and design systems for visitors and editors.
WordPress Modernization
Modernize WordPress for better performance, architecture, and AI readiness.
WordPress as a DXP
WordPress as a composable DXP when monolithic systems no longer cut it.
Headless WordPress
Omnichannel content delivery without sacrificing marketing autonomy.
Frappe/ERPNext
Build scalable ERP and custom applications, from implementation to ongoing support.
Discovery
Strategic consultancy & project roadmap
Growth Services
On demand development & consultation
Site Maintenance
Annual maintenance. Done for you
QE Services
Testing across SDLC for assured quality
Hosting Migration
Move to a performant hosting with zero downtime
WooCommerce
Enterprise commerce delivered without lock-in
AI
Unlock real use cases and integrations
All Services
A suite of services for any need
Technology STACK
eCommerce
Scale your e-commerce with WooCommerce, integrations, and custom extensions for growth.
EasyEngine
Server management tool that makes using WordPress on Nginx easy.
Web Auditor
Performance Audit & Insights for your Website.
rtMedia
A complete media management plugin for WordPress.
Resources

About Us

CLEAR
Resources
Developing for Block Editor and Site Editor
REST API & datastore
State management
Topics
On this page
State management
Overview
Understanding Redux API Design
Simplifying the Redux API Design
WordPress Data Stores
Working with Stores
Handling Loading and Error States
Data API vs. REST API
1. Retrieving the current post type and selected post template:
2. Inserting a block if it doesn't already exist:
3. Reading and updating post meta values:
Last updated on May 26, 2026
State management in Gutenberg
State management in Gutenberg is centered around Redux, the JavaScript library used to handle application state. Gutenberg uses a structured approach to manage the various states within the editor interface, such as blocks, editor settings, and post data, through a system of stores, selectors, and actions.
State management
state management in Gutenberg allows developers to track, modify, and retrieve the state of the editor and its components using a structured approach based on Redux. Selectors fetch the state, actions update it, and middleware handles asynchronous operations, all of which are integrated into a real-time, responsive user experience.
Overview
The WordPress Data API is used to manage the global application state within the editor. It serves as an abstraction over the Redux library, a popular state management solution.
Understanding Redux API Design
In both Redux and the WordPress Data API, the concept of a Store is central. The store holds the global state, which can only be modified through actions. These actions are processed by reducers, which then define how the state evolves. To read the state, you can subscribe to the store and access the current state whenever it updates.
Simplifying the Redux API Design
Key Concepts and Terminology:
- Store: This is where the application’s state and logic reside. The store holds the state and uses reducers to manage state updates.
- dispatch: Used to trigger a change in the store’s state.
- select: Retrieves data from the store.
- subscribe: If you want to monitor changes to a store’s value, you need to subscribe to it. In React, this is done using hooks like
useSelectanduseDispatch.
WordPress Data Stores
The WordPress editor utilizes multiple stores rather than one global store, each designed for different parts of the site. Stores can be accessed using their namespace or imported directly from their respective packages.
coreWordPress Core DataInteract with global settings and core data.core/blocksBlock Types DataManage registered blocks and styles.core/block-editorBlock Editor DataControl the block editor, such as inserting or removing blocks.core/editorPost Editor DataRetrieve information about the current post, such as post type or attributes.core/edit-postEditor UI DataManage the editor’s interface, toggling various UI components.core/noticesNotices DataManage notices within the editor.
Working with Stores
You can interact with a store either by dispatching an action (to update the state) or by selecting data from it. To do so, you need to know the store’s namespace, or you can import it from the @wordpress/package.
import { store } from '@wordpress/...';
import { store as packageStore } from '@wordpress/package';
When importing multiple stores, a common convention is to rename the store with a relevant name.
import { useDispatch } from '@wordpress/data';
import { store as packageStore } from '@wordpress/package';
const { doSomething } = useDispatch(packageStore);
Dispatching actions to update the store can be done through the useDispatch hook:
import { useSelect } from '@wordpress/data';
import { store as packageStore } from '@wordpress/package';
const something = useSelect((select) => select(packageStore).getSomething());
To select data from a store, use the useSelect hook:
import { useSelect } from '@wordpress/data';
import { store as packageStore } from '@wordpress/package';
const { something, somethingElse } = useSelect((select) => {
const { getSomething, getSomethingElse } = select(packageStore);
return {
something: getSomething(),
somethingElse: getSomethingElse()
};
});
For cases where you need multiple values from the same store, group them within a single useSelect call:
Handling Loading and Error States
You can determine whether a select call has been completed using the hasFinishedResolution selector, available in all core stores. This method requires the selector name as its first parameter and any parameters passed to the selector as the second.
Example:
import { useSelect } from '@wordpress/data';
import { store as packageStore } from '@wordpress/package';
const something = useSelect((select) => {
const { getSomething, hasFinishedResolution } = select(packageStore);
const params = ['exampleParam'];
return {
something: getSomething(...params),
hasResolvedSomething: hasFinishedResolution('getSomething', params)
};
});
Data API vs. REST API
While the Data API leverages the REST API behind the scenes, it behaves differently. Data manipulated through the Data API is only saved when the post is explicitly saved. In contrast, direct interactions with the REST API modify and persist data immediately. This makes the Data API the better option for handling post-related data within the editor environment.
Examples of Using the Data API
Note: The useSelect and useDispatch hooks should only be used inside React components. Outside of React components, the select, dispatch, and subscribe functions from @wordpress/data can be used instead.
1. Retrieving the current post type and selected post template:
import { useSelect } from '@wordpress/data';
import { store as editorStore } from '@wordpress/editor';
const { postType, template } = useSelect((select) => ({
postType: select(editorStore).getCurrentPostType(),
template: select(editorStore).getEditedPostAttribute('template'),
}));
2. Inserting a block if it doesn’t already exist:
import { useSelect, useDispatch } from '@wordpress/data';
import { store as blockEditorStore } from '@wordpress/block-editor';
import { useEffect } from '@wordpress/element';
import { createBlock } from '@wordpress/blocks';
const { insertBlocks } = useDispatch(blockEditorStore);
const blocks = useSelect((select) => select(blockEditorStore).getBlocks());
useEffect(() => {
const blockExists = blocks.some((block) => block.name === BLOCK_NAME);
if (!blockExists) {
insertBlocks(createBlock(BLOCK_NAME));
}
}, [blocks]);
3. Reading and updating post meta values:
import { useSelect, useDispatch } from '@wordpress/data';
import { store as editorStore } from '@wordpress/editor';
const { editPost } = useDispatch(editorStore);
const meta = useSelect((select) => select(editorStore).getEditedPostAttribute('meta'));
function setMetaValue(key, value) {
editPost({
meta: { [key]: value }
});
}
This guide provides a clear understanding of how to interact with the WordPress Data API, including accessing and updating state, handling multiple stores, and managing loading states.
Credits
Utsav Patel
Author
Utsav Patel
Author
Good Work. Good People.
Industry partnerships


Compliance certifications
United States
India
© rtCamp Inc. since 2009. All rights reserved.
Terms of Service · Privacy Policy · Trust Center
Company
Solutions
Subscribe to Campfire for fresh insights and stories from people behind rtCamp
Δ
Email(Required)
Submit
United States
India
© rtCamp Inc. since 2009. All rights reserved.
Terms of Service · Privacy Policy · Trust Center
Cookie Consent
We value your privacy
We use cookies to give you the best possible experience. By clicking “Accept,” you consent to our use of cookies to improve site functionality, analyze usage, and personalize content and communications. Your privacy matters to us, and we are committed to handling your data responsibly and transparently. Please check our Privacy Policy for more details.
Manage PreferencesDon’t AllowAllow All
Why do we use cookies?
×
By clicking "Accept" or "Decline All" at the bottom, you consent to the use of cookies and other tools as described in our Cookie Policy in accordance with your settings and accept our Terms of Service.
Toggle EssentialEssential
Essential cookies enable basic functions and are necessary for the proper function of the website.
Name
Description
Duration
Geolocation Config
This cookie is used to store the consent settings based on the visitor's location.
30 days
Cookie Preferences
This cookie is used to store the user's cookie consent preferences.
30 days
Toggle CloudFlareCloudFlare
CloudFlare provides web performance and security solutions, enhancing site speed and protecting against threats.
Service URL: developers.cloudflare.com (opens in a new window)
Name
Description
Duration
cf_clearance
Whether a CAPTCHA or Javascript challenge has been solved.
session
Toggle CommentsComments
These cookies are needed for adding comments on this website.
Name
Description
Duration
comment_author
Used to track the user across multiple sessions.
Session
comment_author_email
Used to track the user across multiple sessions.
Session
comment_author_url
Used to track the user across multiple sessions.
Session
Toggle GodamGodam
GoDAM" is primarily a specialized WordPress plugin and media management service designed to enhance video hosting, marketing, and asset management directly within the WordPress dashboard.
Service URL: godam.io (opens in a new window)
Name
Description
Duration
user_image
Temporarily stores the path to the user's avatar or profile picture for quick rendering in the website header.
session
user_id
Stores the numerical ID of the logged-in user to maintain session continuity and basic site operations.
session
full_name
Stores the logged-in user's display name to personalize the site interface without needing database queries.
session
system_user
First-party cookie used to store basic application state identifying the current system user role.
session
sid
A generic session ID cookie used to maintain user state and functionality as the visitor navigates through the site.
session
Toggle Google reCAPTCHAGoogle reCAPTCHA
Google reCAPTCHA helps protect websites from spam and abuse by verifying user interactions through challenges.
Name
Description
Duration
_GRECAPTCHA
Google reCAPTCHA sets a necessary cookie (_GRECAPTCHA) when executed for the purpose of providing its risk analysis.
179 days
Toggle Google Tag ManagerGoogle Tag Manager
Google Tag Manager simplifies the management of marketing tags on your website without code changes.
Name
Description
Duration
cookiePreferences
Registers cookie preferences of a user
2 years
td
Registers statistical data on users' behaviour on the website. Used for internal analytics by the website operator.
session
Toggle StatisticsStatistics
Statistics cookies collect information anonymously. This information helps us understand how visitors use our website.
Toggle Factors AIFactors AI
Factors.ai is a B2B account intelligence and marketing analytics platform that helps Go-To-Market (GTM) teams identify anonymous website visitors, track buyer journeys, and measure the ROI of marketing campaigns.
Service URL: www.factors.ai (opens in a new window)
Name
Description
Duration
_fuid
It is sent to capture session details and track user behavior across your website to provide behavioral data and intent signals.
1 Year
Toggle Google AnalyticsGoogle Analytics
Google Analytics is a powerful tool that tracks and analyzes website traffic for informed marketing decisions.
Service URL: policies.google.com (opens in a new window)
Name
Description
Duration
FPGSID
Stores a session or user identifier to track how visitors interact with a website. This helps Google Analytics measure website performance, user engagement, and usage patterns.
Session
FPLC
Used by Google Analytics to link visitor interactions and sessions across multiple related domains.
20 hours
FPID
A server-side Google Analytics cookie used as an alternative user identifier when third-party cookies are restricted.
2 years
_ga
ID used to identify users
2 years
_ga_
ID used to identify users
2 years
Toggle Jetpack StatsJetpack Stats
Jetpack's built-in visitor analytics. It records page views, referring sites, search terms, and outbound link clicks, and also carries the shared visitor-tracking library used by Jetpack Instant Search and WooCommerce Analytics.
Service URL: automattic.com (opens in a new window)
Name
Description
Duration
tk_aip
Stores a list of anonymous visitor IDs so they can be merged into one identity once a visitor is recognized.
Up to 5 years
tk_tc
Used once per page load to work out which cookie domain the Tracks library should use, then removed as soon as it's read back.
Session (deleted immediately after use)
tk_qs
Queues analytics events for Jetpack's Tracks library so none are lost if the page closes before they can be sent.
30 minutes
tk_ai
Stores a randomly-generated anonymous visitor ID so Jetpack's Tracks analytics library can link tracking events to the same visitor.
Session in wp-admin; up to 5 years on the frontend
Toggle Microsoft ClarityMicrosoft Clarity
Clarity is a web analytics service that tracks and reports website traffic.
Service URL: clarity.microsoft.com (opens in a new window)
Name
Description
Duration
CLID
Identifies the first-time Clarity saw this user on any site using Clarity.
12 months
ANONCHK
Indicates whether MUID is transferred to ANID, a cookie used for advertising. Clarity doesn't use ANID and so this is always set to 0.
Session
_clck
Persists the Clarity User ID and preferences, unique to that site is attributed to the same user ID.
12 months
_clsk
Connects multiple page views by a user into a single Clarity session recording.
12 months
Toggle Parse.lyParse.ly
Parse.ly is a content analytics platform that helps publishers optimize audience engagement and content performance.
Name
Description
Duration
_parsely_session
JSON document storing information identifying a browsing session according to Parsely’s proprietary definition
30 minutes
_parsely_visitor
JSON document uniquely identifying a browser and counting its sessions
13 months
cookies.js_dtest
This cookie determines whether the browser accepts cookies.
session
Toggle MarketingMarketing
Marketing cookies are used to follow visitors to websites. The intention is to show ads that are relevant and engaging to the individual user.
Toggle Bing / MicrosoftBing / Microsoft
Bing, powered by Microsoft, is a search engine providing web, image, video, and map search capabilities.
Name
Description
Duration
MR
Used to collect information for analytics purposes.
6 months
ANONCHK
Used to store session ID for a users session to ensure that clicks from adverts on the Bing search engine are verified for reporting purposes and for personalisation
10 minutes
SM
Used by Microsoft in synchronizing the MUID across multiple Microsoft domains to track users for advertising.
session
MUID
Identifies unique web browsers visiting Microsoft sites. These cookies are used for advertising, site analytics, and other operational purposes.
1 year
Toggle DoubleClick/Google MarketingDoubleClick/Google Marketing
A comprehensive digital advertising platform for managing campaigns, optimizing performance, and analyzing audience data.
Name
Description
Duration
IDE
This cookie is used for targeting, analyzing and optimisation of ad campaigns in DoubleClick/Google Marketing Suite
2 years
ar_debug
Store and track conversions
Persistent
Toggle LinkedInLinkedIn
LinkedIn is a professional networking platform for job seekers, employers, and industry connections.
Name
Description
Duration
bscookie
Used by LinkedIn to track the use of embedded services.
1 year
AnalyticsSyncHistory
Used to store information about the time a sync with the lms_analytics cookie took place for users in the Designated Countries
30 days
bcookie
Used by LinkedIn to track the use of embedded services.
1 year
li_sugr
Used to make a probabilistic match of a user's identity outside the Designated Countries
90 days
lidc
Used by the social networking service, LinkedIn, for tracking the use of embedded services.
1 day
UserMatchHistory
Used by LinkedIn Ads to synchronize and match user IDs across different ad networks and data providers.
30 days
Toggle LinkedIn InsightLinkedIn Insight
LinkedIn Insight is a web analytics service that tracks and reports website traffic.
Service URL: www.linkedin.com (opens in a new window)
Name
Description
Duration
li_sugr
Used to make a probabilistic match of a user's identity.
90 days
lidc
Used for routing and session management.
24 hours
Toggle LiveIntentLiveIntent
LiveIntent provides a platform for email advertising and identity-driven marketing solutions.
Name
Description
Duration
_lc2_fpi_js
Companion cookie to _lc2_fpi used by JavaScript to facilitate cross-domain ad tracking and user identification.
1 year
_lc2_fpi
First-party tracking cookie usually associated with LiveRamp to identify users across devices for targeted advertising.
1 Year
_li_ss
Sets a unique ID for the visitor, that allows third party advertisers to target the visitor with relevant advertisement. This pairing service is provided by third party advertisement hubs, which facilitates real-time bidding for advertisers.
1 month
lidid
Collects data on visitors' behaviour and interaction - This is used to make advertisement on the website more relevant. The cookie also allows the website to detect any referrals from other websites.
2 years
Toggle Cookie PolicyCookie Policy
You can find more information in our Privacy Policy.
Allow AllDecline All
Accept





