Giter Site home page Giter Site logo

nextjs-supabase-instagram-clone's Introduction

NextJS + Supabase Instagram Clone

Overview

This project was built to try out some cool new libraries with the goal of having a riduculously easy type safe backend that is also pretty powerful and flexible in terms of its querying capabilities and provides good human readbility for a supa-fast DX. The libraries that make this possible are:

  • NextJS ๐Ÿ’ป - SSR and performant frontend with API routes built in learn more
  • Supabase ๐Ÿ”ฅ - BaaS providing auth, storage and a PostgresSQL DB learn more
  • TailwindCSS ๐Ÿ–ผ - Utility style CSS for quickly building out the interface
  • tRPC ๐Ÿ’ช - End-to-end type safety to communicate with our API routes and react-query wrapper learn more
  • Prisma ๐Ÿ’Ž - Database schema controller and ORM with awesome type safety from generated types based off schema learn more

What you might already be able to see is this gives type safety from DB --> Client with the use of Prisma and tRPC. This makes for a pretty seamless DX and gives you a lot of confidence that changes in your data model or API interface will get picked up by your IDE during development ๐Ÿ˜ƒ

Note: This could also be extended for use in React Native with a monorepo style structure - the creator of tRPC also made zART which showcases how this can be achieved

Getting Started

First, we will need to create a Supabase project which you can do by heading over to https://supabase.io. Once that is setup ensure you have email auth enabled.

Then we can create our environment file as follows:

# .env
NEXT_PUBLIC_SUPABASE_HOST="https://<project-id>.supabase.co" # Can be found in Settings > API
NEXT_PUBLIC_SUPABASE_ANON_KEY="your-supabase-anon-key" # Can be found in Settings > API

# Prisma DB URLs - can be found in Databases > Connection pooling
# Ensure you set the port to 6543 on this page too!
MIGRATION_DATABASE_URL="postgres://postgres:##############.supabase.co:5432/postgres"
DATABASE_URL="postgres://postgres:##############.supabase.co:6543/postgres?pgbouncer=true"

Now we can run Prisma to firstly perform our schema migration to Supabase and then generate our Prisma client locally:

npx prisma migrate dev # Will setup the tables we need in Supabase from our schema
npx prisma generate # Will generate our Prisma client with types!

Finally, run the development server:

npm run dev
# or
yarn dev

Open http://localhost:3000 with your browser to see the result.

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.

License

The MIT License (MIT). Please see LICENSE.md for more info

nextjs-supabase-instagram-clone's People

Contributors

thomas-coldwell avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.