🔎 In the wild! Where are you using XState? #255
Replies: 56 comments 24 replies
-
At https://bridge21.com/ we are re-writing our site using XState 3 and react-automata. It's a game changer. Our onboarding is complex with many loops in the process. The stateMachine pattern reduces fragility, making it way easier to add features without breaking past work. I love being able to see the entire app in the visualizer. Our stateMachine has about 90 states so far! All of them quiet necessary. react-automata makes building state dependent interfaces easy |
Beta Was this translation helpful? Give feedback.
-
It's not much but I made a Pomodoro Clock emulator using React and XState with no other intermediary library. I'm using Hooks to subscribe individual components to an XState service. |
Beta Was this translation helpful? Give feedback.
-
Sorry I can't say anything "official" one way or the other, but I thought you'd like to know that we're starting up an internal proof-of-concept at my company to explore the use of XState. We're really interested in the potential of pairing up designers and developers (leveraging something like Sketch) to work together on application flows and behaviours. We can see a lot of use-cases for this approach. Depending on how things turn out, I hope to circle back with more details in the future. |
Beta Was this translation helpful? Give feedback.
-
@adamkl That's awesome, please keep me in the loop! One of the major goals for XState is to be integrated into design environments, similar to https://overflow.io. |
Beta Was this translation helpful? Give feedback.
-
Bumping this 😄 |
Beta Was this translation helpful? Give feedback.
-
We'll release soon a Shopify app, and we started experimenting with Xstate.. I'll let you know as soon as we ship it and I have an url |
Beta Was this translation helpful? Give feedback.
-
Working on a POS system with my clients currently. I'll ask them if they'd be cool with me putting it up as an "in the wild" example. I'm sure they'll be fine with it, but I don't want to jump the gun if they have objections. |
Beta Was this translation helpful? Give feedback.
-
Deployed to production in Kong to handle form states (error, loading, modal, fetch machines etc.) in our Vue app: https://konghq.com/products/kong-manager/ |
Beta Was this translation helpful? Give feedback.
-
Using XState 4 extensively in 4D Healthware's frontend app. |
Beta Was this translation helpful? Give feedback.
-
We are using XState at Meru Health in our React Native app for managing many interactions. I just gave a presentation of using XState at React Helsinki - check it out! 😊 |
Beta Was this translation helpful? Give feedback.
-
I used XState in a touchable app for the Royal Tyrrell Museum (Alberta - Canada) and documented its use in this article: "Modeling a Screensaver with a Statechart, a real use case". |
Beta Was this translation helpful? Give feedback.
-
Used XState for the navigation of a keg analytics web-app BinaryBeer. |
Beta Was this translation helpful? Give feedback.
-
Used XState to model data fetching and filtering of a collection of products 👉 stimm.com
|
Beta Was this translation helpful? Give feedback.
-
Using xstate like crazy in https://serviceworkies.com and all my future games. |
Beta Was this translation helpful? Give feedback.
-
We're now using xstate to power a couple of the more complicated interactions at my place in our Behavior Insights Engine at Maritz. |
Beta Was this translation helpful? Give feedback.
-
We are using XState for coordinating very complex flows on a video-call cross-platform application at @withyourtribe. https://www.withyourtribe.com. |
Beta Was this translation helpful? Give feedback.
-
I've been using xstate for some of the components of a bot I'm writing that lives on the ethereum network. I love it! It's been a total game changer for me, and is extremely reliable. I think that as it's closer to completion, it will be substantially more advanced than other similar bots on the network are. Also it's behaviors will be easier to extend and improve upon I think. Thankyou so much @davidkpiano !! |
Beta Was this translation helpful? Give feedback.
-
I retired from electronics & s/w engineering last century.
Using FSAs in the '80s these kind aspirations were seriously hard work; costlier than the projects I worked on would bear. Thanks and good luck @davidkpiano |
Beta Was this translation helpful? Give feedback.
-
Hello ! At https://www.frichti.co/ we also use xstate in order to handle all our different states ! Thanks for the big work @davidkpiano and all contributors 👏 |
Beta Was this translation helpful? Give feedback.
-
At Fugo.ai, we are building a modern Digital Signage CMS. We are using XState in our players (web version) and in our Design Studio. |
Beta Was this translation helpful? Give feedback.
-
At ThingCo, I've been using it for the past year and a half to manage authentication flows on mobile and web applications (React and React Native). Built a library to wrap the functionality. Sorry for this brain dump but: It's quite a complex machine, one that has to be configurable per client (OTP or username and password, PIN or biometrics, with various other options that relate to authentication flow/device security). The flows are a sequence of async calls, and I've gone back and forth over the best ways to handle this. Also using Typescript, which I've found to be a double-edged sword w/r/t to XState configuration. The library has been through four major iterations now, and I'm tended to agree with most of the observations made in this critical analysis of statecharts (PDF link). I think XState is the gold standard for state machines/statecharts in JS/TS, and I can't see myself using anything else in similar situations to the complex sequential flows I've built, but there's been quite a bit of pain. So the library is structured with a core machine that controls the auth state. That is created via a factory function that allows me to inject config at build time (or in test apps, from a parent React context that does the same thing). That machine is interpreted in a context provider, accessed via hooks in-app. States essentially represent "screens" in the apps. Initially, I wrote a single machine that made use of invoked promises. This rapidly became unmanageable. Context grew, states exploded. So second, third iterations split out functionality. The second iteration used nested machines. This caused severe TS typing issues unless I inlined everything (which defeats the point somewhat). The third iteration used actors, which enabled some nice properties. The context had become pretty populous, and I could reduce that to almost nothing, keeping values within actors. The parent machine could just have an overall state, and that would be what the app used for the app screens, and things like loading/error states remained within the actors. So for example, when making the initial sign in, the actor for the username service starts, it has an idle state for awaiting input, then on input, switch to a loading state, then on success store the response object, tell the parent that was complete, etc etc. This worked, but instead of a state explosion, I got an event explosion. Events had to be defined for both parent and child machines. The number of actions also exploded, because I had lots of small contexts to manage + the parent context. Loading was a problem: there are about 20 different possible async calls, and each time one was invoked, the parent had to be notified. When it was resolved, the parent had to be notified. When there was an error, the parent had to be notified. Then I had to manage starting and stopping of actors. Started using enums extensively to define state ids, action names, guard names, event types, which was horrible but prevented mistakes. Responses from invoked promises have their own internal event types, so all those had to be typed. It all worked and worked well, but it was a nightmare from a developer PoV. About this point, the
So final iteration.
So one machine, almost standard-traffic-light-example simple. Then each state has a corresponding hook (because the state IDs are string enums, I can then use string templating in TS to ensure all states are covered and all states have corresponding selector functions). The hooks accept a callback, which is the API call relevant to that state. This makes debugging them very easy, allows for mock test versions to be injected, and dispenses with having to make API facades. The hooks all return a primary method, which is a function that takes the callback passed to the hook fires it, sending the correct events into the machine at the correct times. This also moves loading/validation errors etc out of the machine context. Overall, model testing is very good if a bit slow -- @xstate/test works excellently, I've got it set up with Jest/React testing library to thoroughly exercise the machine and the hooks that trigger all the machine events, and it's great. The new visualiser stuff is very nice (although running in watch mode when developing and it switching the tab to the visualisation on every code change has been driving me slowly insane for the past three months). Library is great, anyway, apologies for the wall of text. Work I've done is internal, but I may be able to share the structure we have as it doesn't contain any business-specific logic (it's mainly all AWS Cognito-related stuff), I'll have a check |
Beta Was this translation helpful? Give feedback.
-
We also use XState at Back Market 💚 The library itself, that lovely editor of yours and probably soon, the visualizer embedded in back-office pages, to better share the implemented logic with the stakeholders. Looking forward to the awesome v5 in the making 🙌 |
Beta Was this translation helpful? Give feedback.
-
I've recently refactored the bootstrap and authentication phases of a react-native app with great success. I've worked on this app on and off for the last 3 years, and this is the first time this area of the app feels organized and manageable. To give more background, the bootstrap phase of the app has some unfortunate complexity due to design decisions made by the backend team. The api requires a session cookie in order to recover cached details about an authenticated user. The unfortunate thing about session cookies between iOS and Android, is that iOS will forget them after the app is force closed or garbage collected, whereas Android won't. This is because of the underlying implementation of session cookies between platforms. iOS uses Safari's implementation while Android uses Chrome's. So, the problem on iOS was that the app would open fresh with an access token in it's cold store, and try to use this token to make authenticated requests, but would not have a session cookie. The api would see the request as authenticated, but assign a new session cookie to the client, and subsequent requests to other authenticated endpoints would fail because the api could not recover the necessary cached data on this newly assigned session cookie that wasn't properly associated with an authenticated session. Phew. So now the app needed to open, check if it had a session cookie in its cold storage, if it did it would rehydrate this into the device's cookies. Next, the app needed to make a call to a configuration endpoint to get instructions from the api for how to authenticate (which IDP host to call, what client id to use, etc). If the app didn't have a session cookie, this is when it would be assigned one. After this call, the app needed to persist this cookie into cold storage for safe keeping. On top of this, there were various other setup events that needed to occur, such as configuring a background geolocation plugin, etc. With xstate, this sequence of events could be very explicitly modeled as a state machine that does each async step one after the other in a We have also just introduced codepush, and we need to polish the user experience to show them some UI feedback while codepush installs a new OTA update and restarts the app. It is super easy to visualize how this can live in the BootstrapMachine, where the app can be made to show this codepush OTA download/install UI feedback before restarting, checking that it has the most up-to-date codepush version, and continuing on to mount the rest of the normal app. Then there's the authentication sequence in the app, which requires 3 different endpoint calls before we can consider the user authenticated. Previously, this was managed by a series of react component containers that would conditionally mount their children after a given request was completed. This led to the request logic being spread across several components, and made working on anything to do with authentication a painful experience. With xstate, the complexity of this sequence of calls was drastically simplified. The retry logic, and logout on failure of any of the necessary requests because super simple to visualize, handle, extend, add additional analytics, you name it! XState really did wrestle the complexity of these various stages of the app into a very manageable, extendable, readable list of steps. I really can't emphasize how long I've struggled to find a better solution to this complexity. I started with redux and sagas, then |
Beta Was this translation helpful? Give feedback.
-
I use this in my pet-project (aka clone of Toggl, Clockify) for Timer feature, code is open sourced and can be found here https://github.com/bmarvinb/moggl/blob/main/src/features/timer/machines/TimerMachine.ts |
Beta Was this translation helpful? Give feedback.
-
https://github.com/hsndmr/xstate-quiz-app |
Beta Was this translation helpful? Give feedback.
-
The newly launched koordinates v10 UI is almost entirely built with xstate and xstate-tree |
Beta Was this translation helpful? Give feedback.
-
https://github.com/hsndmr/nestjs-auth-starter |
Beta Was this translation helpful? Give feedback.
-
Hey, i thought i'd contribute to this - we are using xstate on Anyone (closed source) - a voice networking app with 5 minute calls written in react native. We use it for the whole phone call flow, signup process, matchmaking for in-app events, post-call reviewing of users, etc. We're so grateful for all the hard work on this awesome library - and the efforts of the community! some of the machines we have: |
Beta Was this translation helpful? Give feedback.
-
These projects are all brilliant to see! Bumping this thread to breathe some life back into it! |
Beta Was this translation helpful? Give feedback.
-
Hi ! The XstateReactiveController is a Lit Reactive Controller specifically designed for straightforward integration with XState. |
Beta Was this translation helpful? Give feedback.
-
If you are using XState in a project/at your company, please post it here!
I'm working on a new "In the wild" docs section (related: #172) and I would absolutely ❤️ to highlight projects that are using XState (version 3 or 4).
If you have:
Please post it here. 😄🙏
Thanks in advance! 💙
Beta Was this translation helpful? Give feedback.
All reactions