パッケージの詳細

react-together

multisynq528Apache-2.00.4.4

A library to seamlessly add real-time multi-user interaction to your React app!

react, together, react-together, real-time

readme

# React Together With React Together, you can easily add real-time multi-user interaction to any React app. No backend or net-code required! [![NPM version][npm-image]][npm-url] [![NPM downloads][download-image]][download-url] [![NPM size][size-image]][size-url] [![Join Discord][discord-image]][discord-url] [![Follow Twitter][twitter-image]][twitter-url] Changelog · [Report Bug][github-issues-url] · [Request Feature][github-issues-url] [npm-image]: https://img.shields.io/npm/v/react-together.svg [npm-url]: https://www.npmjs.com/package/react-together [download-image]: https://img.shields.io/npm/dm/react-together.svg?style=flat-square [download-url]: https://npmjs.org/package/react-together [twitter-image]: https://img.shields.io/twitter/follow/Multisynq.svg?label=Multisynq [twitter-url]: https://twitter.com/Multisynq [size-image]: https://img.shields.io/bundlephobia/minzip/react-together?label=size [size-url]: https://bundlephobia.com/result?p=react-together [discord-image]: https://img.shields.io/discord/1219357019212087419?label=Join%20our%20Discord&color=7289da [discord-url]: https://multisynq.io/discord [github-issues-url]: https://new-issue.ant.design

React Together provides a series of hooks that synchronize state across multiple clients. This allows to build any component you want, such as real-time chat, live cursors and polls, multiplayer games, etc. It also provides a series of pre-built components to help you get started.

📦 Installation

npm install react-together

🔨 Usage

The snippet below shows you how easy it is to create a synchronized counter.

import { useStateTogether } from 'react-together'

export function SynchronizedCounter() {
  const [value, setValue] = useStateTogether('counter', false)

  return <button onClick={() => setValue((p) => p + 1)}>{value}</button>
}

Ready to start using React Together? Check out our Getting Started guide.

🫂 Community

[![Join Discord][discord-image]][discord-url]

Join our active Discord community to get involved with the project, get close support, and share what you're building.


[![Follow Twitter][twitter-image]][twitter-url]

Get up to date with the latest news and announcements.


🔗 Useful Links

🤝 Contributing PRs Welcome

Let's build React Together... together!!

We warmly invite contributions from everyone. Before you get started, please take a moment to review our Contributing Guide. Feel free to share your ideas through Pull Requests or GitHub Issues. Enjoy your coding journey! :)

⌨️ Local Development

To run and test React Together locally, run the following commands:

$ git clone git@github.com:multisynq/react-together.git
$ cd react-together
$ npm install
$ npm run build
$ npm run website # This will start the website
$ npm run playground # This will start the playground

Open your browser and visit http://localhost:5173.

License

Licensed under the Apache License 2.0, Copyright © 2024-present Croquet Labs.

See LICENSE for more information.

更新履歴

0.4.4

2025-05-19

  • update @multisynq/react to 1.0.2

0.4.3

2025-05-27

  • update react peer-dependency to 18 - 19

0.4.2

2025-05-19

  • update @multisynq/react to 1.0.1

0.4.1

2025-05-07

  • Added useIsSynchronized hook

0.4.0

2025-05-07

  • Switched to @multisynq/client

0.3.3

2025-01-29

  • Added Cursors component
  • Added useCursors hook
  • Added useNicknames hook
  • Added useAllNicknames hook
  • Added throttleDelay option to useStateTogether
  • Added throttleDelay option to useStateTogetherWithPerUserValues
  • Added rememberUsers prop to ReactTogether component
  • Added deriveNickname prop to ReactTogether component
  • Added nickname property to ConnectedUser interface
  • Deprecated name property in ConnectedUser interface

0.3.2

2025-01-10

  • Fixed useStateTogether bug with undefined values
  • Added ChatMessage interface

0.3.1

2025-01-09

  • Added omitMyValue option flag in useStateTogetherWithPerUserValues
  • Added useChat hook
  • Added <Chat/> component

0.3.0

2024-12-13

  • Added resetOnDisconnect option flag in useStateTogether
  • Added resetOnDisconnect option flag in useStateTogetherWithPerUserValues
  • Added resetOnConnect option flag in useStateTogetherWithPerUserValues
  • Added keepValues option flag in useStateTogetherWithPerUserValues
  • Added overwriteSessionValue option flag in useStateTogetherWithPerUserValues
  • Added userId prop to ReactTogether component
  • Removed sessionIgnoresUrl attribute from ReactTogether.sessionParams property
  • Added sessionIgnoresUrl prop to ReactTogether component
  • Include CHANGELOG.md in package

0.2.0

2024-11-01

  • Added useFunctionTogether hook
  • Added useCreateRandomSession hook
  • Added useIsTogether hook
  • Added useJoinUrl
  • Added useLeaveSession hook
  • Added useMyId hook
  • Added SessionManager component
  • Added name prop to ReactTogether.sessionParams
  • Added password prop to ReactTogether.sessionParams
  • Added highlightMyself prop to HoverHighlighter component
  • Added utils module with:
    • getSessionNameFromUrl function
    • getSessionPasswordFromUrl function
    • getJoinUrl function
    • getCleanUrl function
  • Renamed ConnectedViews to ConnectedUsers
  • Renamed PresenceDiv to HoverHighlighter
  • Renamed useConnectedViews to useConnectedUsers
  • Renamed useHoveringViews to useHoveringUsers
  • useHoveringUsers now returns whether the local user is hovering the targeted element
  • useHoveringUsers options do not receive the highlightMyself parameter anymore
  • ReactTogether component joins session if rtName and rtPwd specified in URL
  • Reexport @croquet/react as CroquetReact obj
  • Removed useReactTogetherContext

0.1.1

2024-08-31

  • Fixed bugs on useStateTogether
  • Fixed bugs on useStateTogetherWithPerUserValues

0.1.0

2024-08-28

  • Optimize useStateTogether and useStateTogetherWithPerUserValues to minimize unnecessary re-rendering
  • useConnectedViews does not return null
  • Allow to override the session model via sessionParams.model prop of the <ReactTogether/> component
  • Re-export @croquet/react module

0.0.2

2024-08-15

  • Added sessionIgnoresUrl param to <ReactTogether/> component

0.0.1

2024-07-18

  • Added useStateTogether hook
  • Added useStateTogetherWithPerUserValues hook
  • Added useConnectedViews hook
  • Added useHoveringViews hook
  • Added useReactTogetherContext hook
  • Added <ConnectedViews/> component
  • Added <PresenceDiv/> component
  • Added <ReactTogether/> context provider