Hands-on: Note Taking App
Step-by-Step Guide to Creating a Note Taking App with Vite, React, and Supabase
This guide provides a step-by-step update for enhancing the Note-Taking App by integrating authentication, user session management, and CRUD operations with a Supabase database. The updated app will feature a Header with the app title and user email, a SignUp page, and a Dashboard where users can see, create, update, and delete notes.
Step 1: Install Node.js
Before you start, ensure you have Node.js installed. You can check your installation by running:
node -v
npm -vIf Node.js is not installed, download and install it from the official website.
Step 2: Create a New Vite Project
Vite is a fast build tool for modern web applications. To create a new Vite-powered React project, run the following command at Git-bash terminal or PowerShell terminal:
npm create vite@latest react-note-taker-app --template reactAlternatively, if you are using Yarn or PNPM, you can use:
yarn create vite@latest react-note-taker-app --template reactpnpm create vite@latest react-note-taker-app --template reactStep 3: Move into the Project Directory
Once the project is created, navigate into the project folder:
Step 4: Install Dependencies
Run the following command to install the necessary dependencies:
This will install all required packages specified in package.json.
Step 5: Start the Development Server
Then, open Visual Studio Code IDE and open a new terminal . To start the development server and preview the application, run:
This command will provide a local development URL (e.g., http://localhost:5173/) where you can see your app in action.
Now, delete all unnecessary code snippet in App.jsx to get started a new React App creation.
Step 6: Connect to Supabase
a. Create a Supabase Project
Go to Supabase and sign up.
Create a new project and note down the
Project URLandAnon Key.
b. Install Supabase Client
In your project directory, install the Supabase client:
c. Configure Supabase
Create a .env file in the root of your project and add:
Then, in src/supabaseClient.js, initialize Supabase:
Now your project is set up with Vite, React, and Supabase!
Step 7: Create a Database Table for NoteTaking App
Navigate to the Supabase Dashboard → Table Editor and create a new table called notes with the following columns:
id(UUID, Primary Key, Default:gen_random_uuid())title(Text, Not Null)content(Text, Not Null)date(Timestamp, Default:now())iscompleted(Boolean, Default:false)user_id(UUID, Foreign Key referencing auth.users, Not Null)
Step 8: Create Authentication Components(final)
To enable user authentication, install:
Then, Create src/components/Auth.jsx to handle SignUp, SignIn, SignOut, Email Confirmation, and Reset Password.
a. Create Auth Component for SignUp and SignIn(final)
In src/components/Auth.jsx, add:
a. Create an Authentication Handler
Create a new file src/auth.js to handle user authentication:
b. Create Auth Component for SignUp and SignIn (optional)
In src/auth.js, update the code to use auth.js functions:
Now, the authentication logic is centralized in auth.js, making it reusable and maintainable. The application supports sign-up, sign-in, sign-out, password reset, and fetching the authenticated user. Let me know if you need any refinements!(optional)
b. Implement Password Reset (optional)
In src/components/ResetPassword.jsx, add:
Step 9: Update App Header
Modify src/components/Header.jsx to show the app title and logged-in user email.
Step 10: Create the Dashboard Page
In src/pages/Dashboard.jsx, add:
Now your NoteTaker app includes authentication, password reset, and a fully functional dashboard to create, view, update, and delete notes using Supabase!
Step 11: Update App Header(final)
Modify src/components/Header.jsx to show the app title and logged-in user email, with a Sign Out button.
Step 12: Create a Dashboard Component with Card Display for Notes
Modify src/pages/Dashboard.jsx to manage notes and display them in card format.
Step 13: Create a Parent Component App.jsx (final)
App.jsx (final)Create src/App.jsx to integrate the Header, Dashboard, User Authentication, and Routes.
Step 14: Create a Dashboard Component with Card Display for Notes(final)
Modify src/pages/Dashboard.jsx to manage notes and display them in card format.
Step 15: Create a Note Taking Feature(final)
In src/components/FormNote.jsx, add:
The updated app now includes:
A
FormNotecomponent to handle both note creation and updating.Dashboard functionality to create, update, and delete notes.
A new Update button that allows users to edit existing notes.
Step 16: Run the Application
Start the development server:
Conclusion
The updated app now includes a parent App.jsx component that manages routing and integrates authentication, dashboard, and header components for a complete user experience.
Challenge: Step A: Create a Note Taking Feature
In src/components/FormNote.jsx, add:
Step B: SQL Command Operation on Supabase DB table for Policies Setting
Step C: Fetch and Display Notes
In src/components/NoteList.js:
Now your NoteTaker app is fully functional with authentication, database integration, and note management!
Step D: Create a Database Table in Supabase
a. Access Supabase Table Editor
Go to Supabase and log in.
Open your project dashboard.
Navigate to the Table Editor on the left sidebar.
Click New Table .
b. Define Table Schema
Create a new table named notes with the following columns:
id (UUID, Primary Key, Default:
gen_random_uuid(), Not Null)title (Text, Not Null)
content (Text, Not Null)
date (Timestamp, Default:
now(), Not Null)isCompleted (Boolean, Default:
false, Not Null)user_id (UUID, Foreign Key referencing
auth.users.id, Not Null)
c. Save and Deploy
Click Save to create the table.
Ensure the table permissions allow
Authenticatedusers to perform CRUD operations.
d. Configure Row-Level Security (RLS)
Navigate to the Authentication → Policies section.
Click New Policy and select the
notestable.Add a rule that allows users to access only their own notes:
Add policies for insert, update, and delete accordingly.
Now, your Supabase database table is set up and secured!
As an alternative better way, use the SQL command to create the notes table in Supabase with Row Level Security (RLS) enabled:
UUID Setting in RLS Policies
We have to set the column in the database table with a default of auth.uid().
Type: uuid
Default Value: auth.uid()

SQL Command Explanation
The
idcolumn is a UUID primary key generated usinggen_random_uuid().The
user_idcolumn references theauth.users.idfield, ensuring that each note belongs to a specific authenticated user.RLS is enabled to ensure users can only access their own data.
Four security policies are created to allow authenticated users to insert, select, update, and delete only their own notes.
You can execute this SQL command in the SQL Editor of your Supabase project to create and secure the notes table. 🚀
Step E: Integrate Components into App.jsx
a. See step F to create App.jsx
App.jsxModify src/App.jsx to integrate authentication and note-taking functionality:
b. Update Dashboard.jsx
Dashboard.jsxEnsure Dashboard.jsx manages note creation, retrieval, update, and deletion:
Final Steps
Run
npm run devto start the development server.Test authentication and note management features.
Deploy the project using Vercel or Netlify for hosting.
Now your Vite React Note Taker App is fully functional with authentication and CRUD operations using Supabase! 🚀
Repeat Step 13 to accomodate sign out functionality.
Note on 403 Forbidden Error
Step F: Integrate Components into App.jsx
a. Create App.jsx
App.jsxModify src/App.jsx to integrate authentication and note-taking functionality:
b. Update Dashboard.jsx
Dashboard.jsxEnsure Dashboard.jsx includes a sign-out button and correctly saves notes:
c. Update Header.jsx
Step G: Modify FormNote.jsx to Include Date Input and Completion Checkbox
FormNote.jsx to Include Date Input and Completion CheckboxIn src/components/FormNote.jsx, update the form to include an input for the creation date and a checkbox for task completion:
Step H: Modify NoteList.jsx to Display Date, Completion Checkbox, and Delete Button
NoteList.jsx to Display Date, Completion Checkbox, and Delete ButtonIn src/components/NoteList.jsx, update the list to show the note creation date, allow marking completion, and add a delete button:
Step I ::
Step J: Run and Test Your Application
Start your development server with
npm run dev.Add new notes using the form, ensuring they store
dateandisCompleted.Ensure the delete button removes notes successfully.
Verify that notes are stored and retrieved correctly from Supabase.
Now your Vite React Note Taker App includes a date input for note creation, a checkbox for marking completion, and a delete button using Bootstrap icons! 🚀
Last updated