百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

superstate

> 前端框架
开源

--- shell yarn add @superstate/core --- ✨ 简单、流畅、优雅的 API ts import { superstate } from "@superstate/core" const count = supers…

198 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

--- shell yarn add @superstate/core --- ✨ 简单、流畅、优雅的 API ts import { superstate } from "@superstate/core" const count = supers…


bash
yarn add @superstate/core

✨ Simple, sleek & elegant API

typescript
import { superstate } from "@superstate/core"

const count = superstate(0)

count.set(5)

console.log(count.now()) // 5

Yep, that simple. No PhD required.

Mindlessly easy to share state across your entire app

typescript
// count.ts
import { superstate } from "@superstate/core"

export const count = superstate(0)

// calculator.ts
import { count } from "./count.ts"

count.set(5)

// app.ts
import { count } from "./count.ts"

// When calculator.ts changes count, it'll call the callback below! :D
count.subscribe((value) => {
  console.log(value)
})

The trick is the export keyword: to share your state, all you have to do is exporting and importing it.

Designed with ergonomy and developer wellness in mind

superstate puts the developer first—from the beginner to the veteran. No changes are made without thorough consideration and confidence that working with superstate is pure pleasure.

Fully extensible

Instead of building superstate with lots of useless opinionated features, the idea is to give you the tools to expand it as much as you need—and only when you need. Middlewares and Extensions are at your service.

Built-in Drafts System

Great UX doesn't have to be a burden to build. With the built-in Drafts System, you can give your users second chances without spending an extra day on it.

typescript
const count = superstate(0)

count.sketch(5)
console.log(count.draft()) // 5
console.log(count.now()) // 0

count.publish()
console.log(count.draft()) // undefined
console.log(count.now()) // 5

Simple enough for prototypes and scalable enough for the world's next big thing

Regardless of the scale of your project, superstate will fit. It is very compact for prototypes, but if your app hits big, superstate follows along. Have an ongoing application? It's all right—superstate can be incrementally adopted so you don't have to worry if the first rails are already built.

⌨️ Proudly written in TypeScript

Building superstate without TypeScript was never an option.

⚛️ Deadly simple integration with React apps

typescript
import { superstate } from '@superstate/core'
import { useSuperState } from '@superstate/react'

const count = superstate(0)

export const MyComponent = () => {
  useSuperState(count)

  return (
    

       count.set(prev => prev + 1))>Increase
    
  )
}

You read it right: calling the useSuperState(count) hook is all you need to make your component re-render when count increases.

Works in the browser or in Node environments

Browser-only apps, hybrid apps (such as Electron), Node apps... check, check, check!


Brought to you by Guilherme "chiefGui" Oderdenge.


The MIT License (MIT)

Copyright (c) 2022 Guilherme Oderdenge

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptjavascriptreactstate-managementtypescript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架