flâneur — a map of the web's best reading

Uploading files to Supabase storage with Next.js

kirandev.com · 365 words · saved by 1 readers

By default storage buckets are private, so you'll need to add proper RLS policies to allow your users to upload files. Add a policy definition to allow anon users to upload files to the documents bucket. If you want to allow authenticated users to upload files, you can add the following policy definition. Let's create a new route /profile and add a form with a file input. Create a form with a file input and handle the onChange event to upload the file to Supabase Storage. We use the createClientComponentClient function from the @supabase/auth-helpers-nextjs library to create a Supabase client instance. Uploading files to Supabase storage with Next.js

Learn how to integrate Next.js with Supabase Storage to effortlessly upload files. We'll create a form and upload a file into Supabase Storage. Install the Supabase Next.js auth helper library into your Next.js project. npm install @supabase/auth-helpers-nextjs Add your Supabase credentials to a .env.local file. NEXT_PUBLIC_SUPABASE_URL = YOUR_SUPABASE_URL NEXT_PUBLIC_SUPABASE_ANON_KEY = YOUR_SUPABASE_ANON_KEY Make sure you create a storage bucket called documents in your Supabase storage. By default storage buckets are private, so you'll need to add proper RLS policies to allow your users to

Explore this link on the map →

related reading