Skip to content

Deploy to supabase cloud

Supabase Cloud

Supabase provides its own cloud services where you can deploy you local supabase setup along with the db migrations, storage and edge functions.

Setup

Follow these steps to setup your supabase cloud project:

  • Create an account in supabase.
  • Create an organization and add a new project in supabase dashboard.
  • Login to supabase in your local system.
    npm run supabase:login
  • Link your supabase project with your local setup
    npm run supabase:link

Deploy to Cloud

  • Push you local db with policies to the cloud

    npm run supabase:push
  • Push your storage with policies to the cloud. Supabase doesn’t inherently allow storage migrations to be pushed to the cloud, as it considers them seeds instead of db migration. Follow these steps :

    • If you’re using the default storage settings, you can copy this sql query.

      INSERT INTO storage.buckets(id, name, owner_id, public) VALUES ('profile_images', 'profile_images', 'authenticated', true);
      CREATE POLICY "allow insert for authenticated users on bucket profile_images" ON storage.objects FOR INSERT TO public WITH CHECK (bucket_id = 'profile_images');
      CREATE POLICY "allow select for authenticated users on bucket profile_images" ON storage.objects FOR SELECT TO public USING (bucket_id = 'profile_images');
      INSERT INTO storage.buckets(id, name, owner_id, public) VALUES ('cover_images', 'cover_images', 'authenticated', true);
      CREATE POLICY "allow insert for authenticated users on bucket cover_images" ON storage.objects FOR INSERT TO public WITH CHECK (bucket_id = 'cover_images');
      CREATE POLICY "allow select for authenticated users on bucket cover_images" ON storage.objects FOR SELECT TO public USING (bucket_id = 'cover_images');
    • Go to the dashboard of your project, Click on the SQL Editor on the sidebar. Paste the above content in there and click on run, it will setup your storages.

  • Deploy your edge functions to the cloud, this command with deploy all of your edge functions with a single command.

    npm run supabase:fn-deploy
  • Since stripe-webhook will be triggered by strip itself, and hence will not have any authorization in this, so wen deploy only this function with check to not verify any jwt. Use this command for any such functions which only works without the jwt header.

    npm run supabase:webhook-deploy

    or

    # if the function name is different, go to apps/supabase directory and run this command
    npx supabase@latest functions deploy <function-name> --no-verify-jwt