Getting Started with Supabase Local Dev
course
Get started with Supabase on your machine
Browse
Find courses, lessons, articles, talks, and podcasts.
64 resources
Showing 1–24 · Page 1 of 3
course
Get started with Supabase on your machine
lessonDuration 26sFree
Create a Supabase account and database quickly by going to https://database.new
lessonDuration 3m 31s
In common workflows we do not want to push directly to the remote database from our machine. We will setup a github action that will run whenever we push to our main branch of our github repo.
lessonDuration 1m 25s
It is common, when working on a team, for changes to have been applied to a remote database and for your local instance to be out of sync. By running `npx supabase db pull` we can pull any changes to our remote database schema to keep our local database in sync.
lessonDuration 47s
When `npx supabase init`, `npx supabase start`, or `npx supabase db reset` is run, supabase will look for our `seed.sql` file and seed our local database. Since we have already created the project and we want to add seed data, we can run `npx supabase db reset`.
lessonDuration 1m 25s
With Supabase Link we can link our local project to a remote database. Then we can use the command `npx supabase db diff -f <fileName>` to create a local migration file. Then we use `npx supabase db push` to apply our local changes to the remote database.
lessonDuration 44s
With the project setup, we can now start our local instance of supabase. This gives us a local running version of the supabase studio that we can interact with. We will create a table in called todos in the studio
lessonDuration 55s
With our project setup we will use our supabase dev dependency to run the supabase cli. We will login to our supabase account and then init the project locally. To run supabase locally you need to have Docker installed and running on your computer. To install Docker and get it setup visit this link - https://docs.docker.com/desktop/
lessonDuration 43s
Create an application and install packages
lessonDuration 4m 38s
lessonDuration 3m 37sFree
Create a server action for adding a deposit
lessonDuration 3m 16sFree
As we have been doing, refactor the deposit api route handler that handles deleting a deposit into a server action. This video has been sped up. If you want to see the code checkout to the 'solution' branch with `git checkout solution` and look in the 'final' folder in src/app/actions for the delete deposit action.
lessonDuration 1m 48sFree
With our customer POST handler now moved to a server action your goal is to do the same thing with the invoice POST handler
lessonDuration 3m 55sFree
Now that we have done this a few times the encouragement here is for you to find the component that is doing client side data fetching for user info and refactor the api route and client fetching to be a server component If you would prefer to look at the code checkout to the 'solution' branch and look in the final folder and you will find the refactored component.
lessonDuration 3m 17sFree
Now that we have built an intuition for refactoring our api routes and components to server components by refactoring the customer api handlers we can do the same thing for the invoices handlers that fetch data
lessonDuration 22sFree
Your goal is to move the remaining api routes to the app router. If you would like a longer form video, [here is a link](https://youtu.be/27S6qoKJ7uc) to a youtube video with timestamps
lessonDuration 3m 33sFree
UploadThing makes it easy to migrate to the App router with a step by step guide. We'll move our upload functionality to the App router and finally delete our pages directory.
lessonDuration 3m 42sFree
Now that we have moved over the bulk of our routes to the app router we can move the remaining routes to the pages routes app router.
lessonDuration 6m 29sFree
Having moved over all the customer routes, you have everything you need to see how to move over the remaining sales routes from the pages router to the app router This lesson exists purely as a resource if you want to see the walkthrough If you would prefer to look at the code you can checkout out the 'solution' branch and look at the final version with `git checkout solution`
lessonDuration 1m 33sFree
Get up to speed with dynamic/parameter based routing in the new app router by adding a very basic Link and a dynamic route that the Link will navigate us to
lessonDuration 1m 45sFree
Before we start migrating routes we will get a high level understanding of nested layouts in the app router
lessonDuration 2m 54sFree
There are a handful of errors we will run into when we try to redeploy our application now that it is utilizing the app router. After those errors are handled and now that we have moved everything from our pages router to app router and added new features like server actions and experimental hooks we can redeploy our application.
lessonDuration 3m 22sFree
With the experimental_useOptimistic hook we can get optimistic updates to our UI while our mutation completes. After the mutation completes and the path is revalidated our optimistically added deposit will be replaced with the deposit from the database. This hook comes with some caveats however, because of it's experimental nature, we need to disable strict mode in React. While this is functionality that will be super useful in the future, it might not be the best idea to start using it right now.
lessonDuration 1m 17sFree
With zod and error boundaries we can provide UI feedback if form inputs do not pass validation. Here I'll set up an Error Boundary inside the modal to to catch the error that Zod throws. You can check Zod documentation to make these errors more readable and user friendly.