LIVE URL :- Social Media Engagement
- Framework - React
- React Icons - React Icons
- Tailwind CSS - CSS Framework
- Google Firebase - Google Authentication
- Supabase - For database & cloud storage
- Moment - to format timestamps
- React Router Dom - for page routes & navigation
- Swiper - smooth carousel
- React Infinite Scroll Component - For infinite post component loading
- Compressor js - to compress image files.
- React Hot Toast - for toast notifications.
- first clone or download the repo.
- Inside the root folder run the command
npm installto install all the dependencies & after that make.env.localfile in root dir. - In the .env.local file paste the code below, for this project to run it locally you can use my api keys.
VITE_SECRET_SUPABASE_KEY= YOUR SUPABASE SECRET KEY
VITE_FIREBASE_KEY= YOUR FIREBASE API KEY
- After doing everything above mentioned, run the server using
npm run dev.
- Users can authenticate using google auth & data will be stored in the database.
- Create Post by posting images/video with title.
- Users can view & edit their profile by updating their bio, name, profile & banner image.
- Logout functionality.
- Users can like another and their own post.
- Smooth navigation & interaction, plus all the post feed doesn't get loaded at once, only when user scroll further.
- The main challenge is completing the project but rather to find correct tools for things you want to build.
- First thing was authentication, I was thinking to make the whole app with only google firebase but they have removed free tier plan to use their cloud storage, which was a bummer to me. Then the only option which was left to me was
Appwrite, but I thought I should try something different, because I wanted the google auth for authentication. - Therefore I decided that I will clerk for authentication & supabase for database & cloud storage. I've never worked with supabase only heard it's name a few times, but I can say it is something work out, I mean it's awesome,fast,easy to setup & there's so much for.
- Another issue was after deploying the app on vercel clerk after sign in didn't redirect to feed page, it rather redirects to some
unknown page. And there goes my very basic feature in the trash can. Then I decided if I can't get it work on next day until afternoon I'll have to look for different options. Hence I chosegoogle firebasefor google auth & it had no issues & worked flawlessly with only minor changes in my code.
- I've worked with uploading files on cloud storage in my chat app, but never with handling multiple files saving them to cloud storage using
inputtag. - But I just need to checkout the documentation & stack overflow, it was smooth as butter.
- Then the problem came with compressing image files because some image files can be huge, maybe more than
5 mbs& the compression should be done on client side. I used compressor js for it but the problem arised that I can't getcompressorjsto return the compressed file. I tried with functions, making another component & using hooks likeuseState&useEffectbut nothing works. That is when the promise came to play, it solved the problem entire, I just have to return resolve on success of compression.
- At first the approach I was looking to take for updating profile was to first delete the existing img file & add the new one, but then I find in the supabase documentation that we can replace an existing file in cloud storage.
- I tried it & got success, but the problem when we upload the file for the first time in cloud storage it caches it, so even after replacing it with another one still shows the old
cachedimage file. - Therefore I decided to go with my first approach & it worked as I expected.
- Why did I say that making something from scratch is like solving a
puzzle, you have to put piece together in a way that it looks right & meaningful.