<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Gaurav Asawa</title>
    <description>The latest articles on DEV Community by Gaurav Asawa (@gaurav_asawa_5292153b9086).</description>
    <link>https://dev.to/gaurav_asawa_5292153b9086</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4239009%2F69d20fb7-16aa-4b18-a831-fb5759732556.jpg</url>
      <title>DEV Community: Gaurav Asawa</title>
      <link>https://dev.to/gaurav_asawa_5292153b9086</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gaurav_asawa_5292153b9086"/>
    <language>en</language>
    <item>
      <title>I Built a State Management Library That Works Like React's useState</title>
      <dc:creator>Gaurav Asawa</dc:creator>
      <pubDate>Wed, 11 Nov 2026 12:20:52 +0000</pubDate>
      <link>https://dev.to/gaurav_asawa_5292153b9086/i-built-a-state-management-library-that-works-like-reacts-usestate-j2b</link>
      <guid>https://dev.to/gaurav_asawa_5292153b9086/i-built-a-state-management-library-that-works-like-reacts-usestate-j2b</guid>
      <description>&lt;h1&gt;
  
  
  I Built a State Management Library That Works Like React's useState — Meet CreateStore
&lt;/h1&gt;

&lt;p&gt;If you've worked with React, you've probably used &lt;code&gt;useState&lt;/code&gt; countless times.&lt;/p&gt;

&lt;p&gt;It's simple, predictable, and gets the job done.&lt;/p&gt;

&lt;p&gt;But as an application grows, things get a little more complicated. You have components deeply nested in the component tree that need access to the same state. Suddenly, you're passing props through multiple components, introducing Context Providers, or bringing in a state management library with its own concepts and boilerplate.&lt;/p&gt;

&lt;p&gt;I kept thinking:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why can't sharing global state be as simple as using &lt;code&gt;useState&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That question led me to build &lt;strong&gt;CreateStore&lt;/strong&gt;, a JavaScript state management library that I've recently published on npm.&lt;/p&gt;

&lt;p&gt;In this article, I'll walk through the problem, how CreateStore approaches it, and how you can start using it in a React application.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem with sharing state in React
&lt;/h2&gt;

&lt;p&gt;Let's say we're building a simple todo application.&lt;/p&gt;

&lt;p&gt;We have two components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;TodoCount&lt;/code&gt; – displays the number of todos.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;AddTodo&lt;/code&gt; – allows users to add new todos.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With regular React state, we might lift the state to a common parent and pass it down through props.&lt;/p&gt;

&lt;p&gt;As the application grows, this approach can become difficult to maintain.&lt;/p&gt;

&lt;p&gt;React Context is another option, but it introduces providers and additional setup.&lt;/p&gt;

&lt;p&gt;Libraries like Redux solve much larger state management requirements, but sometimes you don't need that much ceremony for straightforward shared state.&lt;/p&gt;

&lt;p&gt;I wanted something that felt familiar to React developers without introducing another complicated mental model.&lt;/p&gt;

&lt;h2&gt;
  
  
  Meet CreateStore
&lt;/h2&gt;

&lt;p&gt;CreateStore is a global state management library built around one simple idea:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Write your state once. Access it anywhere. Keep the API familiar.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here's what makes it interesting:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No Context Providers.&lt;/li&gt;
&lt;li&gt;No reducers.&lt;/li&gt;
&lt;li&gt;No action types.&lt;/li&gt;
&lt;li&gt;No unnecessary configuration for basic global state.&lt;/li&gt;
&lt;li&gt;TypeScript support.&lt;/li&gt;
&lt;li&gt;Components subscribe to the keys they actually use.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And when your application needs more, CreateStore provides optional capabilities such as computed values, server queries, persistence, offline support, undo/redo, and cross-tab synchronization.&lt;/p&gt;

&lt;p&gt;You don't have to enable everything upfront.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Install CreateStore
&lt;/h2&gt;

&lt;p&gt;First, install the package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="sb"&gt;`npm install @createstore/createstore`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Requirement:&lt;/strong&gt; React 19 or newer.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Create your global store
&lt;/h2&gt;

&lt;p&gt;Create a file called &lt;code&gt;store.ts&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="sb"&gt;`import { createStore } from '@createstore/createstore';

type Todo = {
  id: number;
  text: string;
  done: boolean;
};

export const { useGlobalState } = createStore({
  todos: [] as Todo[],
  filter: 'all' as 'all' | 'open' | 'done',
});`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it.&lt;/p&gt;

&lt;p&gt;You've created a global store with two keys: &lt;code&gt;todos&lt;/code&gt; and &lt;code&gt;filter&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;No reducers, providers, or additional setup required.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Read and update state from different components
&lt;/h2&gt;

&lt;p&gt;Now let's create two independent components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Component 1: TodoCount.tsx&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="sb"&gt;`import { useGlobalState } from './store';

export function TodoCount() {
  const [todos] = useGlobalState('todos');

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h2&amp;gt;Total Todos: {todos.length}&amp;lt;/h2&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Component 2: AddTodo.tsx&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="sb"&gt;`import { useGlobalState } from './store';

export function AddTodo() {
  const [todos, setTodos] = useGlobalState('todos');

  const addTodo = () =&amp;gt; {
    const newTodo = {
      id: Date.now(),
      text: 'Explore CreateStore',
      done: false,
    };

    setTodos([...todos, newTodo]);
  };

  return (
    &amp;lt;button onClick={addTodo}&amp;gt;
      Add Todo
    &amp;lt;/button&amp;gt;
  );
}`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice something?&lt;/p&gt;

&lt;p&gt;Both components access the same global state using the same familiar hook.&lt;/p&gt;

&lt;p&gt;When &lt;code&gt;AddTodo&lt;/code&gt; updates the todos, &lt;code&gt;TodoCount&lt;/code&gt; automatically receives the updated state.&lt;/p&gt;

&lt;p&gt;They don't need to be directly connected through props or wrapped in a Context Provider.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. What about features beyond global state?
&lt;/h2&gt;

&lt;p&gt;This is where I wanted CreateStore to go beyond just sharing values between components.&lt;/p&gt;

&lt;p&gt;Real applications need more than basic state management.&lt;/p&gt;

&lt;p&gt;For example, you might need:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Computed values&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Derive values from existing state without maintaining duplicate state.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Server data&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Fetch data using the store's query capabilities, including parameterized and paginated queries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Persistence&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Keep selected state available even after a page reload.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cross-tab synchronization&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Keep state synchronized across browser tabs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Offline support&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Support offline workflows and queued server updates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Undo and redo&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Track state history and move backwards or forwards when needed.&lt;/p&gt;

&lt;p&gt;These capabilities are available through optional store configuration and APIs. You can explore each feature in the documentation.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Configure only what you need
&lt;/h2&gt;

&lt;p&gt;Here's an example of enabling some optional features:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="sb"&gt;`import { createStore } from '@createstore/createstore';

const { useGlobalState } = createStore(
  {
    cart: [] as string[],
    theme: 'light' as 'light' | 'dark',
  },
  {
    name: 'shop',
    persist: true,
    history: true,
    syncTabs: true,
    offline: true,
    devtools: true,
  }
);`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of adding multiple tools for every requirement, CreateStore aims to bring these capabilities under one consistent store API.&lt;/p&gt;

&lt;p&gt;You can also start with a basic store and add features as your application grows.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Is CreateStore for every React application?
&lt;/h2&gt;

&lt;p&gt;Honestly, no.&lt;/p&gt;

&lt;p&gt;If you're managing a simple input value or a component-specific toggle, React's built-in &lt;code&gt;useState&lt;/code&gt; is perfectly fine.&lt;/p&gt;

&lt;p&gt;CreateStore is more useful when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiple components need access to shared state.&lt;/li&gt;
&lt;li&gt;You're tired of passing props through multiple component levels.&lt;/li&gt;
&lt;li&gt;You want a familiar API for global state.&lt;/li&gt;
&lt;li&gt;You want shared client state and server data capabilities in one library.&lt;/li&gt;
&lt;li&gt;You prefer enabling features as your application needs them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's another option in the React ecosystem, and I'd love to see how developers use it in real projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I built it
&lt;/h2&gt;

&lt;p&gt;For me, this project was about more than creating another npm package.&lt;/p&gt;

&lt;p&gt;I wanted to take an everyday development problem, explore a possible solution, build something from scratch, write documentation, and make it available for other developers.&lt;/p&gt;

&lt;p&gt;There are already excellent state management libraries in the React ecosystem. CreateStore isn't about replacing all of them.&lt;/p&gt;

&lt;p&gt;It's about exploring a simpler approach to global state management.&lt;/p&gt;

&lt;p&gt;And now that it's published, the most valuable next step is getting real developers to try it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Give CreateStore a try!
&lt;/h2&gt;

&lt;p&gt;If you're a React developer, I'd genuinely appreciate it if you could check out the project.&lt;/p&gt;

&lt;p&gt;📦 &lt;strong&gt;npm package:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://www.npmjs.com/package/@createstore/createstore" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/@createstore/createstore&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📚 &lt;strong&gt;Documentation:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://createstore-docs.pages.dev/" rel="noopener noreferrer"&gt;https://createstore-docs.pages.dev/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;💻 &lt;strong&gt;GitHub repository:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://github.com/Gauravasawa/createstore" rel="noopener noreferrer"&gt;https://github.com/Gauravasawa/createstore&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'd love to hear your thoughts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does the API feel intuitive?&lt;/li&gt;
&lt;li&gt;Would you use this in a real-world project?&lt;/li&gt;
&lt;li&gt;What features would you like to see?&lt;/li&gt;
&lt;li&gt;Did you find any bugs or unexpected behaviour?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Feel free to open an issue or contribute on GitHub.&lt;/p&gt;

&lt;p&gt;I'm looking forward to improving CreateStore with feedback from the developer community.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Built with curiosity, shared with the community. Happy coding! 🚀&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;If you try it out, please share your experience. Every bit of feedback helps.&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  ReactJS #JavaScript #TypeScript #WebDevelopment #FrontendDevelopment #OpenSource #NPM #SoftwareEngineering #Programming #Coding #DeveloperCommunity #BuildInPublic #ReactDevelopers #StateManagement #GitHub #TechCommunity #WebDev #FullStackDevelopment #100DaysOfCode #LearnToCode #DevTools #ReactHooks #JavaScriptDeveloper #OpenSourceCommunity #SoftwareDevelopment #NextJS
&lt;/h1&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>typescript</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
