npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

strapi-provider-upload-supabase-bucket

v1.0.0

Published

Upload files to Supabase Storage from Strapi v5 with public and private bucket support

Readme

Strapi Provider Upload Supabase

npm version npm downloads License: MIT

Upload files to Supabase Storage from Strapi v5 with support for both public and private buckets.

Features

  • ✅ Strapi v5 compatible
  • ✅ Node.js 20 and 22 support
  • ✅ TypeScript with full type definitions
  • ✅ CommonJS and ESM support
  • ✅ Public buckets (permanent URLs)
  • ✅ Private buckets (time-limited signed URLs)

Installation

npm install strapi-provider-upload-supabase-bucket

Requirements

  • Node.js >= 20.0.0 and <= 22.x.x
  • Strapi >= 5.0.0
  • Supabase project with a storage bucket

Quick Start

1. Environment Variables

Add to your .env file:

SUPABASE_API_URL=https://your-project.supabase.co
SUPABASE_API_KEY=your-service-role-key
SUPABASE_BUCKET=your-bucket-name
SUPABASE_DIRECTORY=uploads
SUPABASE_PUBLIC_FILES=true
SUPABASE_SIGNED_URL_EXPIRES=3600

2. Plugin Configuration

Create or update config/plugins.ts (or config/plugins.js for JavaScript):

TypeScript:

export default ({ env }) => ({
  upload: {
    config: {
      provider: 'strapi-provider-upload-supabase-bucket',
      providerOptions: {
        apiUrl: env('SUPABASE_API_URL'),
        apiKey: env('SUPABASE_API_KEY'),
        bucket: env('SUPABASE_BUCKET'),
        directory: env('SUPABASE_DIRECTORY', ''),
        publicFiles: env.bool('SUPABASE_PUBLIC_FILES', true),
        signedUrlExpires: env.int('SUPABASE_SIGNED_URL_EXPIRES', 3600),
      },
      sizeLimit: 250 * 1024 * 1024, // 250MB
    },
  },
});

JavaScript:

module.exports = ({ env }) => ({
  upload: {
    config: {
      provider: 'strapi-provider-upload-supabase-bucket',
      providerOptions: {
        apiUrl: env('SUPABASE_API_URL'),
        apiKey: env('SUPABASE_API_KEY'),
        bucket: env('SUPABASE_BUCKET'),
        directory: env('SUPABASE_DIRECTORY', ''),
        publicFiles: env.bool('SUPABASE_PUBLIC_FILES', true),
        signedUrlExpires: env.int('SUPABASE_SIGNED_URL_EXPIRES', 3600),
      },
      sizeLimit: 250 * 1024 * 1024, // 250MB
    },
  },
});

3. Security Configuration

Update config/middlewares.ts (or config/middlewares.js) to allow Supabase URLs:

module.exports = [
  'strapi::logger',
  'strapi::errors',
  {
    name: 'strapi::security',
    config: {
      contentSecurityPolicy: {
        useDefaults: true,
        directives: {
          'connect-src': ["'self'", 'https:'],
          'img-src': [
            "'self'",
            'data:',
            'blob:',
            'market-assets.strapi.io',
            'https://your-project.supabase.co', // Replace with your project URL
          ],
          'media-src': [
            "'self'",
            'data:',
            'blob:',
            'market-assets.strapi.io',
            'https://your-project.supabase.co', // Replace with your project URL
          ],
          upgradeInsecureRequests: null,
        },
      },
    },
  },
  'strapi::cors',
  'strapi::poweredBy',
  'strapi::query',
  'strapi::body',
  'strapi::session',
  'strapi::favicon',
  'strapi::public',
];

Configuration Options

| Option | Type | Required | Default | Description | |--------|------|----------|---------|-------------| | apiUrl | string | Yes | - | Supabase project URL | | apiKey | string | Yes | - | Supabase service role key | | bucket | string | Yes | - | Storage bucket name | | directory | string | No | '' | Subdirectory for file organization | | publicFiles | boolean | No | true | Public (true) or private (false) bucket | | signedUrlExpires | number | No | 3600 | Signed URL expiration (seconds, private only) |

Public vs Private Buckets

Public Buckets (publicFiles: true)

Files are accessible via permanent public URLs without authentication.

https://your-project.supabase.co/storage/v1/object/public/bucket/uploads/file.jpg

Best for: Public assets, images, documents

Private Buckets (publicFiles: false)

Files require time-limited signed URLs for access.

https://your-project.supabase.co/storage/v1/object/sign/bucket/uploads/file.jpg?token=...

Best for: User documents, sensitive files, access-controlled content

Accessing Private Files

// Get file from Strapi
const file = await strapi.plugins.upload.services.upload.findOne(fileId);

// Generate signed URL
const provider = strapi.plugins.upload.provider;
const { url } = await provider.getSignedUrl(file);

// Use the temporary URL (expires after signedUrlExpires seconds)
console.log(url);

Supabase Setup

  1. Go to your Supabase dashboard
  2. Navigate to StorageNew bucket
  3. Create a bucket (choose Public or Private)
  4. Get credentials from SettingsAPI:
    • Project URL → SUPABASE_API_URL
    • service_role key → SUPABASE_API_KEY

Troubleshooting

Files not displaying

Check config/middlewares.js includes your Supabase URL in CSP directives.

Upload fails

  • Verify apiUrl, apiKey, and bucket are correct
  • Ensure you're using the service_role key (not anon key)
  • Check bucket exists in Supabase

Private bucket signed URLs not working

  • Verify bucket is set to Private in Supabase
  • Check publicFiles: false in configuration
  • Ensure signed URLs are regenerated before expiration

Testing

Tested and verified on:

| Bucket Type | Node 20 | Node 22 | |-------------|---------|---------| | Public | ✅ | ✅ | | Private | ✅ | ✅ |

Privacy

This provider does not collect, track, or transmit any usage data. All operations are performed directly between your Strapi instance and your Supabase project.

Security

  • Never commit your service_role key to version control
  • Use environment variables for all credentials
  • Set appropriate signedUrlExpires duration for private buckets
  • Implement proper authentication before generating signed URLs

License

MIT

Links

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.


Made with ❤️ for the Strapi community