React Native file upload with Supabase Storage
A React Native app built with Expo SDK 49 and Expo Router v2 can sign users in with Supabase Auth and upload images to a private Supabase Storage bucket. A Postgres storage policy restricts each user to a folder named after their auth UID. The Supabase client persists sessions in AsyncStorage, and an AuthProvider context built on onAuthStateChange redirects between login and protected routes. Upload works by reading the image-picker URI as base64 with expo-file-system, decoding it to an ArrayBuffer and calling storage upload().
Related posts
- Getting started with React Native authentication
Supabase mediumAdeptSupabase Auth can be wired into an Expo/React Native app by configuring supabase-js with AsyncStorage for session persistence and disabling URL session detection. Sessions can optionally be encrypted with an AES-256 key held in Expo SecureStore, which works around SecureStore's 2048-byte limit. The guide includes code for email/password sign-in, plus OAuth and magic-link flows that rely on a custom URL scheme, deep linking and setSession from the redirect tokens. Sign in with Apple, Google sign-in and SMS/WhatsApp OTP get only brief mentions, with pointers to the docs.
- Offline-first React Native Apps with Expo, WatermelonDB, and Supabase
Supabase mediumAdeptAn offline-first React Native/Expo app can use WatermelonDB (SQLite-based, last-write-wins sync) as its local store and sync to Supabase Postgres through two RPC calls: a `push` function that applies client changesets and a `pull` function that returns all changes since the last sync timestamp. The walkthrough covers adding simdjson via expo-build-properties, defining WatermelonDB models, and writing the PL/pgSQL push/pull and epoch-conversion functions, with soft deletes tracked via deleted_at/last_modified_at. The main tradeoff is friction when changing the data model, since the Postgres schema, the local WatermelonDB schema and the sync functions must all be kept in step. That makes the approach best suited to apps with a stable schema where snappy interactions matter.
- Storage is now available in Supabase
Supabase mediumAdeptSupabase Storage is an object store built as a custom TypeScript/Fastify API server behind Kong, with object metadata and access policies kept in each project's Postgres database and objects stored in S3. Existing servers like Minio, Ceph and Zenko were rejected because they couldn't use Postgres as their datastore, carried features unnecessary on managed backends, and didn't map to Supabase Auth. Authorization uses Postgres Row Level Security on a storage.objects table: if a user can select or delete the row, they can read or delete the object, so policies are written in SQL and listing filters happen in the database. Uploads stream through Node streams to S3 with minimal buffering, trading off knowing the object size upfront, and objects get a default 1-hour Cache-Control header.
- Supabase Auth: SSO, Mobile, and Server-side support
Supabase mediumAdeptSupabase Auth adds SAML 2.0 single sign-on, a PKCE authorization flow for server-side rendering and mobile apps, and native Sign in with Apple on iOS. SSO providers are managed with new `supabase sso` CLI commands, and the provider identifier in the JWT can drive Postgres Row Level Security policies for multi-tenant isolation. PKCE replaces the implicit grant flow, which exposed tokens in URL fragments that servers can't read and that malicious mobile apps could intercept. It does this with a hashed code verifier and challenge, so an intercepted authorization code is useless on its own. Enabling it means setting `flowType: 'pkce'` in supabase-js, and a Next.js callback route exchanges the code for a session.
- supabase-js v2
Supabase mediumAdeptsupabase-js v2 brings incremental quality-of-life changes over v1. Types are now generated from the database via the CLI and set once on the client. signIn() is split into signInWithPassword() and signInWithOtp(), server-side auth moves to auth.admin, and the auth library is now async to fix a multi-tab token refresh race condition that logged users out. insert/update/upsert no longer return data unless select() is appended, which avoids surprise failures under Row Level Security. Constructor config is scoped per sub-library, each sub-library gets typed errors, Edge Function invocations auto-detect content type, and a new channel() API replaces from().on() for realtime and Postgres change subscriptions. v1 gets security and maintenance patches for three months.