Follow me on Twitter to get this article and others free: @SquashBugler
Vercel has made some great libraries and frameworks in the past so it’s no surprise that the SWR library would be any different. I’m going to show you how to fetch and manipulate data from a REST API with Vercel’s SWR library. This post has a quick overview of the Vercel library, but if you want to learn more about the library and how it works, you can read the full documentation here.
The idea behind SWR which stands for stale while revalidating is defined in the docs as such. “SWR is a strategy to first return the data from cache (stale), then send the fetch request (revalidate), and finally come with the up-to-date data.” So what does this have to do with CRUD? In case you didn’t know CRUD is a set of operations that are performed on data and it is shorthand for create, read, update and delete. By default, SWR will perform the read part of this for you by returning the result of a fetch request. But if you want to expand this you will have to mutate the cache from that request. That’s why I created a useCrud hook that will help us do just that. I also incorporate Typescript to ensure that the proper keys are used when updating the cache so you will need to have that set up as well. …
Follow me on Twitter to get this tutorial and others: @SquashBugler
Gatsby is a great framework for building and designing a website but what about authentication? Well That’s where firebase comes in, I’ve read a few articles and posts about how to integrate firebase with GatsbyJS but most of them didn’t involve typescript support. They also failed to explain keeping a user logged in, or setting up private routes. It’s important that authentication be tracked in the browser and app state. That’s why my approach will provide further customization and help you follow security best practices, let’s get started!
First, you’ll want to add the Gatsby client globally, use either depending on preference but I prefer…
For me first starting out with HTML and CSS I thought it would take years and a bachelor’s degree to land a job, I was very wrong.
It’s been a joke for some time that I’ve told but unfortunately, the punchline is real for too many poor souls. How many todos does it take to get a job as a developer?
You know because there are a million todo app tutorials out and more come out each year. It’s been done so many times that I can imagine a world where prospective employers take todo apps as currency for employment.
The sad thing is that I feel that many of those who read this will miss the irony of this post. Trust me tutorial hell exists because I’ve been there. …
Follow me on Twitter to get this article and others: @SquashBugler
A lot of starting developers wonder what is the best way to export something. Maybe for you it’s just about your personal preference and what you’re used to but surely there must be some sort of best practice right? Should you use default exports or named? Should you export from the file itself or an index? The answer to these questions is yes.
I'm going to make a bold statement here. The code you write isn't for you. (Unless you're the type that enjoys being a hermit and never working with others). …