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:

2 Likes

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?

Would you be able to detail the layout of your database.js file? Or other plugins / mods needed to make supabase an option for use as a db? :pray:

Were you able to setup Strapi + Supabase Postgres. I am facing an error that Unable to acquire connection from pg module in strapi.

Probably Strapi making so many reqs while migratoin causes this!

From the docs: Database | Strapi Documentation

:warning: Warning
Strapi applications are not meant to be connected to a pre-existing database, not created by a Strapi application, nor connected to a Strapi v3 database. The Strapi team will not support such attempts. Attempting to connect to an unsupported database may, and most likely will, result in lost data.

So im not sure it is supported?