Giter VIP home page Giter VIP logo

supabase-next.js's Introduction

Full stack blog with Supabase and Next.js

This code goes along with the blog post The Complete Guide to Full Stack Development with Supabase and Next.js published here

To get started with this project, follow these steps.

  1. Create a new project in the Supabase dashboard

  2. Click on SQL in the left menu, and execute the following SQL query:

CREATE TABLE posts (
  id bigint generated by default as identity primary key,
  user_id uuid references auth.users not null,
  user_email text,
  title text,
  content text,
  inserted_at timestamp with time zone default timezone('utc'::text, now()) not null
);

alter table posts enable row level security;

create policy "Individuals can create posts." on posts for
    insert with check (auth.uid() = user_id);

create policy "Individuals can update their own posts." on posts for
    update using (auth.uid() = user_id);

create policy "Individuals can delete their own posts." on posts for
    delete using (auth.uid() = user_id);

create policy "Posts are public." on posts for
    select using ( true );

Run either locally or deploy to Vercel

Deploying to Vercel

Deploy with Vercel

Running locally

  1. Clone this project
git clone https://github.com/dabit3/supabase-next.js.git
  1. Change into the directory and install the dependencies
cd supabase-next

npm install
  1. Create a file named .env.local and update it with the values from your Supabase project:
NEXT_PUBLIC_SUPABASE_URL=https://app-id.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-public-api-key

App URLs

  1. Run the server
npm run dev

supabase-next.js's People

Contributors

dabit3 avatar mannycolon avatar oliverturner avatar programbo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

supabase-next.js's Issues

How to make posts private for a user?

In the getStaticProps method in the posts/[id].js file, there is the following query to Supabase:

  const { data } = await supabase
    .from("posts")
    .select()
    .filter("id", "eq", id)
    .single();

According to the Readme, we set up Row Level Security with the following policy:

create policy "Posts are public." on posts for
    select using ( true );

In a production setting, this means that a user could technically access Supabase directly i.e

const { data } = await supabase.from("posts").select()

To get all of the posts in the database, including ones they did not author.

Is there a configuration change that would make the posts private, or only accessible to the authoring user?

Thanks for the great open source template, it worked perfectly otherwise.

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.