 Hey, everyone. Sam here. Today, we'll learn how to handle online and offline states in your page the standard way. This will work with any framework or library. So let's go. Your device is going to be online with full access to the internet or offline. But there's actually a third state called Wi-Fi. This can happen when you're, say, connected to Wi-Fi, but there's no data flowing through that pipe, like this unplugged Wi-Fi router here. I'm on, I'm connected, but I'm getting nothing. So let's take a look at this. So I have this site I'm working on that fetches the weather for a location. Users leave it open and will refresh every few minutes. First thing, we'll check the property navigated.online. Yes, with an uppercase L. If this is false, we're definitely offline. So we'll show an error or some other message and probably the previous weather data. However, if this property is true, it doesn't mean we're online. We could be in this Wi-Fi state like I mentioned before. So we actually want to make a request for our data and see if it fails. If we get an error like a four or four or a 500, this is actually still a success. We can talk to the server and it gave us that response. But if we get an error or a promise rejection, this is actually a proper network error. We're actually offline and we can't find the other server. So now you know your state and your page can deal with it as if you're offline. We can show previous data. Now, best practice would be to retry the request later. You should automatically retry the request, but make sure you use exponential backoff. This means do a request after one minutes, two minutes, four minutes and so on, so you don't overload your server. And if your browser supports the background sync API, this is even easier as it handles the retry for you. Read more about that here. And also, listen for the browser's online event. This is fired when the online property changes back to true. Something has changed. Maybe you're still in Wi-Fi mode, but it's a great time to check again what state you're in. My best advice is that you should check for errors when making these kinds of network requests so that you can make a choice if you find out your users are offline. Your page can recover gracefully. This is really just one part of working well offline or with spotty network connections. If you'd like to learn more about serving your whole site offline, be sure to read up on service workers which act as an intermediate network proxy. So remember, check the navigator.online property, but don't trust it and install error handlers on your network requests. That's online and offline the standard way. See you on the next tip.