Cloudflare worker and Supabase
Supabase has made it easy to hit your Supabase API from a Cloudflare worker using their JavaScript package @supabase/supabase-js.
Under the hood their library uses cross-fetch which will not work within the Cloudflare worker environment, but they now support a custom fetch client. In the case of Cloudflare workers, native fetch is already available so no new library is needed.
import { createClient } from '@supabase/supabase-js'
// Provide a custom `fetch` implementation as an option
const supabase = createClient('https://xyzcompany.supabase.co', 'your-key', {
fetch: (...args) => fetch(...args),
})
Here is an example where I am using it within one of my projects.