Video: Local-first Apps with ElectricSQL and React

Rate this content
Bookmark
Slides
Video Summary and Transcription
ElectricSQL is a local-first sync layer that integrates seamlessly with React, allowing developers to build modern applications directly on top of Postgres. This approach prioritizes local-first architecture, which enhances user experience by minimizing latency and enabling offline functionality. ElectricSQL employs a unique active-active replication model, supporting real-time multi-user sync across platforms even when offline. Developers can define Postgres schemas and use shapes to control data syncing, optimizing performance and resource usage. The system ensures transactional causal plus consistency, preventing conflicts and maintaining data integrity. ElectricSQL eliminates boilerplate code and simplifies operational processes, providing cost savings and a high-quality user experience. More information can be found on ElectricSQL's website and community platforms like Discord and GitHub.

This talk has been presented at React Day Berlin 2023, check out the latest edition of this React Conference.

FAQ

Local-first systems offer instant reactivity, offline capabilities, and eliminate network latency by embedding a local database within the client, which allows applications to function even if the server goes offline.

Developers can start by defining their schema using Postgres tools, running the Electric sync service, and wrapping their SQL Driver with Electric SQL's API. Detailed guides and demo information are available on Electric SQL's website.

James Arthur is the CEO and one of the co-founders of Electric SQL.

Electric SQL uses an Elixir sync service that runs in front of Postgres to handle bi-directional active-active replication, ensuring that changes in the local database are synchronized with the server and vice versa.

CRDTs (Conflict-free Replicated Data Types) are data structures that automatically resolve conflicts in distributed systems. Electric SQL's team includes two of the inventors of CRDTs.

Electric SQL achieves transactional causal plus consistency, the strongest consistency mode for offline-capable applications, ensuring no conflicts during offline writes and preserving relational data integrity.

Shapes in Electric SQL define what data is synchronized to the local device, enabling dynamic partial replication. Developers can specify subsets of data to sync, which helps in optimizing performance and resource usage.

Electric SQL can be used to build applications like Figma, Linear, and other modern consumer or prosumer apps that require instant reactivity, offline functionality, and multi-user collaboration.

Electric SQL is a local-first sync layer that integrates with React to build modern applications directly on top of Postgres. It enables instant reactivity, offline capabilities, and multi-user collaboration by embedding a local database in the client.

The CAP theorem states that a distributed system can only provide two out of three guarantees: Consistency, Availability, and Partition Tolerance. Electric SQL focuses on the AP (Availability and Partition Tolerance) side of the theorem to enhance application performance and resilience.

Video transcription and chapters available for users with access.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Everything Beyond State Management in Stores with Pinia
Vue.js London Live 2021Vue.js London Live 2021
34 min
Everything Beyond State Management in Stores with Pinia
Top Content
State management is not limited to complex applications and transitioning to a store offers significant benefits. Pinia is a centralized state management solution compatible with Vue 2 and Vue 3, providing advanced devtools support and extensibility with plugins. The core API of Pinia is similar to Vuex, but with a less verbose version of stores and powerful plugins. Pinia allows for easy state inspection, error handling, and testing. It is recommended to create one file per store for better organization and Pinia offers a more efficient performance compared to V-rex.
Using useEffect Effectively
React Advanced 2022React Advanced 2022
30 min
Using useEffect Effectively
Top Content
Today's Talk explores the use of the useEffect hook in React development, covering topics such as fetching data, handling race conditions and cleanup, and optimizing performance. It also discusses the correct use of useEffect in React 18, the distinction between Activity Effects and Action Effects, and the potential misuse of useEffect. The Talk highlights the benefits of using useQuery or SWR for data fetching, the problems with using useEffect for initializing global singletons, and the use of state machines for handling effects. The speaker also recommends exploring the beta React docs and using tools like the stately.ai editor for visualizing state machines.
React Query: It’s Time to Break up with your "Global State”!
React Summit Remote Edition 2020React Summit Remote Edition 2020
30 min
React Query: It’s Time to Break up with your "Global State”!
Top Content
Global state management and the challenges of placing server state in global state are discussed. React Query is introduced as a solution for handling asynchronous server state. The Talk demonstrates the process of extracting logic into custom hooks and fixing issues with state and fetching logic. Optimistic updates with mutation are showcased, along with the benefits of using React Query for data fetching and mutations. The future of global state management is discussed, along with user feedback on React Query. The Talk concludes with an invitation to explore React Query for server state management.
Jotai Atoms Are Just Functions
React Day Berlin 2022React Day Berlin 2022
22 min
Jotai Atoms Are Just Functions
Top Content
State management in React is a highly discussed topic with many libraries and solutions. Jotai is a new library based on atoms, which represent pieces of state. Atoms in Jotai are used to define state without holding values and can be used for global, semi-global, or local states. Jotai atoms are reusable definitions that are independent from React and can be used without React in an experimental library called Jotajsx.
Announcing Starbeam: Universal Reactivity
JSNation 2022JSNation 2022
27 min
Announcing Starbeam: Universal Reactivity
Starbeam is a library for building reactive user interfaces with JavaScript, similar to Svelte, Vue, and Ember. It provides a data structure and query feature for filtering and sorting. The useStarBeam function ensures JSX reconciliation only occurs when reactive dependencies change. Starbeam tracks every read and write operation to update the component accordingly. It can be used with React and other frameworks, and offers debugging tools and locale integration.
Thinking in React Query
React Summit 2023React Summit 2023
22 min
Thinking in React Query
Top Content
Watch video: Thinking in React Query
React Query is not a data fetching library, but an Asian state manager. It helps keep data up to date and manage agent life cycles efficiently. React Query provides fine-grained subscriptions and allows for adjusting stale time to control data fetching behavior. Defining stale time and managing dependencies are important aspects of working with React Query. Using the URL as a state manager and Zustand for managing filters in React Query can be powerful.

Workshops on related topic

Rethinking Server State with React Query
React Summit 2020React Summit 2020
96 min
Rethinking Server State with React Query
Top Content
Featured Workshop
Tanner Linsley
Tanner Linsley
The distinction between server state and client state in our applications might be a new concept for some, but it is very important to understand when delivering a top-notch user experience. Server state comes with unique problems that often sneak into our applications surprise like:
- Sharing Data across apps- Caching & Persistence- Deduping Requests- Background Updates- Managing “Stale” Data- Pagination & Incremental fetching- Memory & Garbage Collection- Optimistic Updates
Traditional “Global State” managers pretend these challenges don’t exist and this ultimately results in developers building their own on-the-fly attempts to mitigate them.
In this workshop, we will build an application that exposes these issues, allows us to understand them better, and finally turn them from challenges into features using a library designed for managing server-state called React Query.
By the end of the workshop, you will have a better understanding of server state, client state, syncing asynchronous data (mouthful, I know), and React Query.
State Management in React with Context and Hooks
React Summit Remote Edition 2021React Summit Remote Edition 2021
71 min
State Management in React with Context and Hooks
WorkshopFree
Roy Derks
Roy Derks
A lot has changed in the world of state management in React the last few years. Where Redux used to be the main library for this, the introduction of the React Context and Hook APIs has shaken things up. No longer do you need external libraries to handle both component and global state in your applications. In this workshop you'll learn the different approaches to state management in the post-Redux era of React, all based on Hooks! And as a bonus, we'll explore two upcoming state management libraries in the React ecosystem.