Skip to main content
View on YouTube to comment and like!

Syntax Video

Zero Sync Makes Local First Easy

Chapter 1 00:00

Transcript

but just check out how fast this is I can't even type this fast enough look at how incredibly fast it is to load all of this data zero sync is the local first platform of my dreams and I truly believe this thing is going to change the game forever in how we build web apps because the demo I'm about to show you is incredibly good and I've been using this tool for the past few months I I I was one of the first people to get access to zero uh before it was in Alpha and I got a demo of this zero bugs repo way back then and my jaw was on the floor the whole time this thing absolutely rips and let me tell you just a little bit about this it's from the creators of replicas so uh they have a lot of experience building sync systems

and local first platforms repash was a really great platform you've seen me talk about it on this channel where you did the mutations client side and it sent a message to your server you then personally had to parse those patch messages and then manipulate the database on your own server code and that was great but it was a lot of work it was a lot of work to both deal with the patch messages as well as create the patch messages from when you're pulling information you had to set up server set server sent events you had to do a whole lot just to get the kind of Baseline functionality that you'd want from one of these platforms and while I did really love using replic cach it always felt like I was doing too much now zero really solves every single one of those problems in the best way possible now let me tell you about some of the problems that zero sols that other local first platforms have one you can bring

your own database this U some of the these platforms they want to be your database they want to be your store there's a a platform I really liked called instant DB that's trying to be like a a Firebase competitor that one you have to store all of your data inside of their database well this you can bring your own postgress database and not every feature of postgress is supported but a good amount of them are and we'll talk about that in just a second either way you bring your own DB which means you can bring your own data two you can host it yourself there's a zero server you can host yourself you're not paying someone to host this server for you it's not on a third-party server you can host it anywhere you'd like yourself which I know is exciting for a lot of people given that a lot of these platforms don't give you that option uh three it's open source you can see the source it's great uh got to love an open source platform for many reasons uh but me personally I just like having that assurance that it will exist even if the

company that is running the servers is no longer existing or something like that again you can host it on your own infrastructure uh four it is fast as hell um it's fast it's incredibly fast to use you'll see in just a second just how very fast it is with no effort from the user's part many of these other things can be very fast but they require a lot of mental overhead to get there and five really is that it is easy you're not having to worry about the sync system you're not having to worry about the Cloud Server whatever you're doing server you're seriously you're writing mutations you're writing F statements directly in your client side code and everything is happening behind the scenes now you still get access to be able to fine-tune uh permissions and things like that but you're not having to worry about actually writing code that saves to the database itself it's really Exquisite and I'll show you all of that and more so let's take a look at this demo before I show you any a bit how it works but this is the zero bugs

demo I'll make a uh this available this is a public site this the zero team has been working on this demo for a while to just show you how fast this is so first and foremost you click into an issue and you can see how fast it is they also added keyboard shortcuts in here so if I hit the J key it goes to the next issue they did this so that you can see just truly how fast loading data is in this platform again this data is persisting to a database right so we're loading at at some point we're loading from a database that's loading into your local data the site loading from that local data you mutate that local data and behind the scenes it sends patch messages but just check out how fast this is I can't even type this fast enough look at how incredibly fast it is to load all of this data and you might be thinking all right maybe it's pre-loaded all of these well I refresh look I hit it with a refresh ah look at that I

cannot stress enough how amazing this is and and you will find this to be even that much cooler when you see the type of code you use to create things like this and likewise yeah you need to be logged in to create an issue but you know what every single thing on this site feels as fast as humanly possible it is just shocking um the whole thing is shocking honestly um and I felt this way when I got the demo and I was really like wow this is a good this is a good demo right and so I wanted to take some time and I've been working with this uh I've been working on like the spel bindings for it I've been just using this platform to build several things for a little bit here and I got to say in practice it is as good as it is to use as it is to develop on here this is just so so how is this this fast well it's this fast because if we head into

our Dev tools inside of application it's storing your information in a local database and anytime you change anything or you load anything or you you anytime you do anything the first thing it does is pull it from the local database and then behind the scenes it handles that sync it handles that push and persistence to your database so now that you've gotten the zbug demo right it's their kind of red carpet demo the thing they want you to see uh let's take a look at a quick demo that I threw together so to show you this in action I want to show you this really quick here's first and foremost I'm updating the database on every keystroke so if I just hit like that and I refresh you can see it's not only persisting to the local database but it's already updated the database remotely as well it's that fast and I can save this with every single keystroke you can see I hit it with the refresh and you still get near instantaneous loads this is incredible this is in development this is not even a production build you can see I'm running it on my local host and

furthermore let me show you a little bit of what you can do with this thing I created this quick little survey app which uh Believe It or Not survey apps are a little bit complex and and mine is still just verely getting there but let's go ahead and I'm going to edit one of these surveys and I'll expand this to show you in here that this right here is an anonymous window so it's not logged in it's not even in the it's not in the same browser profile this is an incognito window and since a lot of this stuff is happening through websockets you get real time for free so I can say what really is My AG again and you can see as I'm typing here it's updating here the most incredible thing about all of this again is at any given point I refresh it it's persisting it's persisting to the remote and the local database I can even change maybe the type of question that is in the survey uh this undefined is a a my bug on my part here but uh really

pretty really pretty neat what is going on man I just love this let me show you the code that it takes to make this okay now my code is going to be the spelt version of this I'm using my own spelt Bindings that I have available on GitHub but for the most part let me tell you what you do you create a zero instance so I'm creating a z now I'm putting this into a local store but uh don't worry about that I'm creating a z instance with the following things I'm grabbing the user ID from a JWT I give it the path to the public server I give it a schema of which I've created from zero and I'm giving it a JWT for my op okay so that's creating Z as an instance now anytime I want to do anything with this I use Z and I'm bringing Z in from my from my cache context so this is just Z right here and I'm able to say z. query and then the data type and then I can

use their own language zql I grab one of them you can even do relations here so for each survey I want to grab all of the questions and inside of the questions I want to grab the answers too and then I want to grab the responses this is the entirety of the code it takes to get that Dynamic responsive data loading that's it I just wrap it in this new query uh to create a class now in the react version and the solid version there are hooks there's uh platforms for them to use Query and you basically do the same thing where you're passing in z. query. whatever and the same thing goes for mutations as well so anytime you can see I'm going to answer here I'm using cache. z. mutate then the collection. update and then I'm just passing in my information in here or an insert for creating information as well let's take a look at the schema really quick because it's really not that complex I got to restart typescript

that's why I'm getting this an underline here but you're just running this create table schema I'm creating a profile that has the following columns I'm creating a user schema that has the following columns and then I give it a relationship where I set up my relationships now I also have a drizzle schema for migrations and those types of things but if you're good with postgress or you can write my sequel by hand or you write your your migrations by hand you could do that uh that's that's no problem I use drizzle because I'm not good at that stuff uh so I end up having kind of two schemas I know there are some folks working on drizzle two schema translation and stuff which I personally would love to have so um maybe at some point that will exist either way you create this schema from here you drop in in create a schema and that gives you your schema here of which you pass into things and everything becomes fully typed you can see I can export any of my types from here but anytime I do queries as well uh that information becomes fully typed and in fact I can show you that here we have a simple query surveys

where we're we're quering to find a survey where it matches the page progams and we're grabbing one of them you can see that it has all of the information here exactly and that's incredible man all this stuff is is nicely typed so I can even see I have a a type issue here um but it's awesome okay let's get back to the schema here I'm going to show you permissions really quick I haven't fully set up permissions in fact I just have undefined for everything just to open them up but the way you handle permissions is uh typically through a JWT where you're giving zero the uh the code to decode your JWT and that kind of spits out your off as off data right here and then you can say uh you can write your own functions like I'm going to allow this if logged in and then you get to utilize this CMP to say all right this is utiliz this is allowed wherever the user ID in the data incoming is equal to that same user ID that is

stored within the JWT so you have full access to not only set up your permissions for reading but also writing updating Etc um that's all within here I'm going to be working on much more in-depth examples in fact uh you remember I did a local first tutorial using replicas I'm going to redo that using zero and you're going to just be shocked at how much easier it is so before we get out of here I wanted to show you just a little bit of the zero docks in fact uh they have a whole lot of stuff in there's some really good quick starts if you're a react user if you're a solid user you're going to be eating very well because there are great Integrations there's great documentations there's full stack uh versions where you have o and everything like that like for instance for my spelt version of this app I had to build in my own o system so I had to write my my own off system I'll make this public too this is in my drop in repo so I wrote my own off system works nice either way uh either way you can use all kinds of O system whether that's open o or anything

like that um as far as things go here you can connect to postgress super easily you set it via an EnV variable there's not much there supported postgress features is the only thing that's really um something you want to spend some time with here because you can see that does accept all of these things where you can use an enum and in your schema you use this um likewise Json jsonb dates time stamps all that stuff so a lot of the the basic features most features in postgress are are utilized there is some stuff in here so you might want to take a look at it if you're a heavy postris user for me I'm like always working with the basics that goes deep inside of the schema stuff that we talked about the zql as they call it is the Z zero query language which I've personally found as far as om query languages to go to be extremely straightforward um order by where so if find issue where and then grab one of them otherwise it will grab

an array uh relationships are incredibly easy writing data is via inserts or updates like I showed before oth again is what I mentioned permissions is how I mention but it goes much deeper than I showed or am doing you can even preload data with the preload method on here it also supports schema versions as well so you can version your schema which is really super nice for people who want to make sure they're managing everything correctly uh deployment again uh there's a Docker image you can use to deploy zero cash uh for the zero server and for the most part again you're going to be just deploying that server you're going to use it as a URL connect it to your app and there is your server um there's some interesting stuff in here but it's fairly trivial to get going so this stuff is all amazing you want to check out the road map this is an alpha still this is an alpha so there's going to be bugs there will be issues um like I said I've been using this since the apis have

been changed so I'm very used to things changing within zero uh but in it's current iteration I'm extremely stoked for it looks like they're trying to get to Beta in Q2 of 2025 um so this is a library that is definitely in flux still but if you are as excited about this demo the Z debugs demo just how fast this stuff is as I am check out zero sync this is the platform of my dreams and I do feel like this is going to be the first platform that really takes local first into a position where a lot of people are going to be using it because it is really really super impressive and I think people are going to start talking about this so if you'd like to see more local first content on this channel let me know my name is Scott as always again I love this stuff and I will be doing full-on tutorials whether it is react spelt uh any of that stuff let me know what you want to see from this do you have any

questions or comments about zero do you have any concerns about it is there anything that you are skeptical about in this platform have you tried zbug if not I'll link this demo below and you can give it a try check this stuff out though and if you want to follow along with my survey app or anything like that I'm building it in my drop in repo I'll also make that available in the description below what I'm doing actually is a starter kit for zero um and I want it to be very meteor in felt like so out of the box you get templates for logging in you get user accounts you get local first you get um you get the websocket you get real time and you get some base Styles in a grid system so hey

Quote it with credit and a link. Quoting Syntax