Giter Site home page Giter Site logo

ringge / react-native-next-supabase-auth-monorepo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mateoguzmana/react-native-next-supabase-auth-monorepo

0.0 0.0 0.0 13.47 MB

Supabase Authentication Example | React Native + Next.js Monorepo

License: MIT License

Shell 0.77% JavaScript 6.10% Ruby 1.97% C++ 11.08% Objective-C 3.79% Java 24.75% TypeScript 37.51% CSS 3.62% Objective-C++ 7.07% Makefile 2.39% Starlark 0.96%

react-native-next-supabase-auth-monorepo's Introduction

React Native + Next.js Monorepo | Authentication with Supabase

demo.mov

Authentication starter kit for React Native and Next.js in a monorepo using Supabase for the DB and React Native Web to share components across the projects.

Getting started

Fork or clone this repo and then follow the steps below.

Project set up

Note: Some steps were taken from https://supabase.com/docs/guides/with-nextjs

Before we start using the starter kit we're going to set up our Database and API. This is as simple as starting a new Project in Supabase and then creating a "schema" inside the database.

Create a project

  • Go to app.supabase.com.
  • Click on "New Project".
  • Enter your project details.
  • Wait for the new database to launch.

Set up the database schema

Now we are going to set up the database schema. We can use the "User Management Starter" quickstart in the SQL Editor, or you can just copy/paste the SQL from below and run it yourself.

  1. Go to the "SQL Editor" section.
  2. Click "User Management Starter".
  3. Click "Run".
-- Create a table for public "profiles"
create table profiles (
  id uuid references auth.users not null,
  updated_at timestamp with time zone,
  username text unique,
  avatar_url text,
  website text,

  primary key (id),
  unique(username),
  constraint username_length check (char_length(username) >= 3)
);

alter table profiles enable row level security;

create policy "Public profiles are viewable by everyone."
  on profiles for select
  using ( true );

create policy "Users can insert their own profile."
  on profiles for insert
  with check ( auth.uid() = id );

create policy "Users can update own profile."
  on profiles for update
  using ( auth.uid() = id );

-- Set up Realtime!
begin;
  drop publication if exists supabase_realtime;
  create publication supabase_realtime;
commit;
alter publication supabase_realtime add table profiles;

-- Set up Storage!
insert into storage.buckets (id, name)
values ('avatars', 'avatars');

create policy "Avatar images are publicly accessible."
  on storage.objects for select
  using ( bucket_id = 'avatars' );

create policy "Anyone can upload an avatar."
  on storage.objects for insert
  with check ( bucket_id = 'avatars' );

Get the API Keys

Now that you've created some database tables, you are ready to insert data using the auto-generated API. We just need to get the URL and anon key from the API settings.

  1. Go to the "Settings" section.
  2. Click "API" in the sidebar.
  3. Find your API URL in this page.
  4. Find your "anon" and "service_role" keys on this page.

Now that you have the API URL and keys, let's create the environment variable files.

  1. Navigate to packages/mobile and create a .env file. You can use the .env.sample file as a template and then paste your API URL and key.

  2. Navigate to packages/next and create a .env.local file. You can use the .env.local.sample file as a template and then paste your API URL and key.

I am working on a way to unify this environment variable setup, bare with me :)

Building the project

Install the dependencies:

yarn install
cd packages/mobile && npx pod-install

Then you can run the project:

yarn all

To run the app in iOS, Android & web.

Or

yarn ios
yarn android
yarn web

Note: To run the project in a specific platform.

react-native-next-supabase-auth-monorepo's People

Contributors

mateoguzmana 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.