Using Supabase for the Postgres Database

Is it possible and has anyone tried using the Postgres SQL database offered by Supabase for the Strapi data source? Any tips on setting this up would be greatly appreciated.

I think it should be possible as supabase provide the DB credentials for direct access but there are often some gotchas in these setups.

Thanks

Dan

I am currently using supabase and have no issues. Just use the connection info under project settings > database > connection info. The install was really straightforward. I am also using supabase for media storage (utilizing the plugin that’s available for that). The README for the supabase upload plugin is not correct. You’ll have to add this section to your config/plugins.js and the associated variables to your .env file.

upload: {
  config: {
    provider: 'strapi-provider-upload-supabase',
    providerOptions: {
      apiUrl: env('SUPABASE_API_URL'),
      apiKey: env('SUPABASE_API_KEY'),
      bucket: env('SUPABASE_BUCKET'),
      directory: env('SUPABASE_DIRECTORY'),
      options: {}
    },
    breakpoints: {
      xlarge: 1920,
      large: 1000,
      medium: 750,
      small: 500,
      xsmall: 64,
    },
  },
},

In addition, I had to add CSP configuration to config\middlewares.js.

{
  name: 'strapi::security',
  config: {
    contentSecurityPolicy: {
      directives: {
        'default-src': ["'self'"],
        'img-src': ["'self'", 'data:', 'blob:', '<YOUR_SUPABASE_DOMAIN>'],
      },
    },
  },
},

See for CSP info:

1 Like

Thank you, that’s very useful. I was just looking for that confirmation that someone had it working.

Dan

What about using the Supabase user table in stead of the default strapi user table?
That looks a little more complex.

Anyone solved that?

1 Like

I think my approach would be just to use the supabase auth and users for my customer accounts and only use the strapi accounts for internal use in the CMS.

I do hope that this setup will work and not cause conflicts.

I’d love to hear of anyone who has actually gone this way.

Another open question: do the real-time features work if you manage the content with strapi?

I would really love to see this too. If someone could write a guide, just post here what they’ve done or good resources they found, that would be much appreciated.

Strapi has great functionality as a Content Management System.
Supabase allows me to do all that other fancy back-end, high-performance and low-level stuff for my project (I love their database functions and their batteries included back-end).

In my use-case, an e-commerce where products, blog posts, media, etc can be managed in Strapi (storage-like, rarely touched, less performance needed as stuff would mostly just get fetched on build-time).
Then let orders, customers, shipping, financials, etc be handled through supabase (performance-focused).

Somewhat separation of concerns, with some interoperability as orders still need some of the product data.

I want Strapi to sit next to or on top of Supabase, to have them work in tandem on the same database as their shared source of truth.
Having them share the same database just means less duplicating of data, code to make the two communicate and sync, and probably over-all costs. It just feels nice to have one database as the one source of truth for my project that still allows me to use both Strapi and Supabase on top of it, as the great tools they both are.

Please let me know your view of it all, criticize my idea and tell me how it could be achieved.