Member-only story
SwiftUI and Redux — Clean Code and Small, Independent Components
How to use the Redux library and integrate it in your SwiftUI app

Redux is really cool, SwiftUI is even cooler, and having both in the same app is heaven on earth. So, yet again, I’ll try to convince you that this is the best (or worst) SwiftUI app architecture.
During the past few weeks, I’ve evolved my small, naive Redux SwiftUI library. I’ve added a readme which barely explains how to make it work in your app, but I have a working example anyway.
More importantly, I’ve added StoreProvider
, StoreConnector
, and ConnectedView
.
I can’t thank Alexey Demedeckiy enough, as the new additions are heavily inspired by his earlier work on SwiftUI and Redux. I’ve added it to my library and refactored part of MovieSwiftUI with it. It works wonders with my pre-existing Redux architecture.
I won’t talk about Redux concepts in this article, this is a tutorial on how to use the library and integrate it into your SwiftUI app.
It’ll, of course, give you an overview of how it all works together but it’s more about components architecture. For explanations, you can refer to my previous article linked in the first paragraph.
That said, let’s dig into the code.
Any SwiftUI project will have a SceneDelegate
— this is a new class since iOS 13/macOS 10.15, which manages the windows instances and presentation of your app.
This is basically the new entry point and where you’ll initialize your root-view hierarchy.
In our case, we’ll also create our Redux initial state
and provide it to our store
, then wrap it using StoreProvider
around our root view.