본문 바로가기

What I Learnd/TIL

TIL - Supabase React 셋업

https://supabase.com/

 

Supabase | The Open Source Firebase Alternative

Build production-grade applications with a Postgres database, Authentication, instant APIs, Realtime, Functions, Storage and Vector embeddings. Start for free.

supabase.com

 

1. 회원가입 (git으로 가입 가능)

2. 새로운 프로젝트 생성

3. 데이터 생성

4. 내 프로젝트와 연결

  • supabase 설치
  • Project URL과 API keys 가져와서 프로젝트와 연결

Problem

이 과정에서 anon public 코드를 바로 복사해서 붙여 넣으니 데이터가 불러와지지 않았다.
그 아래에 있는 secret 키를 넣으니 불러와지기는 했지만 public 키로 불러오는 것이 목적이므로-

 

Solve

이유는 내가 만들어준 데이터 테이블에 policy를 지정해주지 않았기 때문이었다.

supabase dashboard / Authentication / Configuration > Policies
각 데이터 테이블에 해당하는 policy를 설정해줘야 한다. 그렇게 세팅을 바꿔주고 나면 Applied to : public 으로 변경된 것을 확인할 수 있었고, 데이터도 잘 불러와졌다.

 

 

참고 웹사이트 https://galaxies.dev/react-supabase

 

How to use Supabase with ReactJS

Learn to integrate Supabase with React to create powerful apps with SQL database.

galaxies.dev