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

@bojidar-bg/tina-simple-media-store

v0.1.2

Published

An alternative MediaStore for TinaCMS with better support for self-hosted installations.

Downloads

29

Readme

A cooler media store for TinaCMS

So.. we've all been there. You read that TinaCMS offers you Repo-based Media storage... however, when you look at the issue list, you find out that, mysteriously, "repo-stored media isn't currently supported when self-hosting". What a pity!

Well, SimpleMediaStore comes to the rescue, by implementing a TinaCMS-compatible MediaStore on top of a local folder, somewhere, anywhere you want, with optional integration for @bojidar-bg/tina-simple-git-provider!

(The need for this package would go away the moment Tina's built-in MediaStore starts supporting a custom URL for the media API and Tina's built-in media store backend is decoupled from the CLI.)

Usage

To use this media store in your TinaCMS application, you need to do two things:

  1. Include the client-side part of the media store in your config.
  2. Import and configure the server-side part of the media store in your handlers.

Client-side part

Modify your TinaCMS config.ts like so:

import { defineConfig } from "tinacms";
// import type { SimpleMediaStoreConfig } from "@bojidar-bg/tina-simple-media-store";

export default defineConfig({
  // ... Other config options
  media: {
    loadCustomStore: async () => (await import("@bojidar-bg/tina-simple-media-store")).SimpleMediaStore,    
  },
  mediaStoreOptions: {
    /// The URL to the media API backend.
    mediaApiUrl: "/api/media",
    // mediaApiUrl: "https://my-tina-api.my-site.example/api/media",
    
    /// The file path from the root of your website's repository to where media files can be found
    mediaRoot: "/",
    
    /// Web address under which media thumbnails can be accessed
    thumbnailBasePath: "" // Defaults to config.build.basePath
    
    /// An image `img.png` uploaded in folder `dir`, would be referenced as `/mediaRoot/dir/img.png` in the Tina editor, and displayed as a thumbnail from `/thumbnailBasePath/mediaRoot/dir/img.png`
  },
});

Server-side part / backend API

The server-side handler, SimpleMediaHandler, expects to be registered under /api/media using Express.js, before TinaCMS's TinaNodeBackend gets registered. If you have a setup similar to the tina-true-selfhosted-example, you can modify your tina/handler.ts to include the SimpleMediaHandler like so:

import { TinaNodeBackend } from '@tinacms/datalayer'
import { SimpleMediaHandler } from '@bojidar-bg/tina-simple-media-store/express'

import { config } from './config'
// import { gitProvider } from './database' // For the SimpleGitProvider integration
import databaseClient from './__generated__/databaseClient'

let authProvider = ... // Your Tina AuthProvider

const tinaHandler = TinaNodeBackend({
  authProvider,
  databaseClient,
  options: {
    basePath: '/tina/',
    // ...
  }
})

const mediaHandler = SimpleMediaHandler({
  authProvider, // An AuthProvider for authenticating media API usage
  paths: {
    // Paths to control where media files should be stored
    rootPath: "/path-to-a-repository-checkout-for-git-backed-media",
    // rootPath: gitProvider.options.repoDir // For the SimpleGitProvider integration
    publicFolder: config.build.publicFolder,
    mediaRoot: config.mediaStoreOptions?.mediaRoot ?? '',
    // Media will be stored in ${rootPath}/${publicFolder}/${mediaRoot}
    // You should ensure it's accessible over HTTP at /${mediaRoot} on your website
  },
  // onModifyFile: gitProvider.makeCommit // For the SimpleGitProvider integration
  onModifyFile: (path) => {console.log(`Media file modified: ${path}`)},
})

// ...elsewhere, to link it all in express

import express from "express"
import cookieParser from "cookie-parser"

export default function createApp() {
  let app = express()
  app.use(cookieParser())
  app.use(express.json())
  app.use(express.urlencoded({ extended: true }))
  
  // Important: Include the SimpleMediaHandler before Tina's NodeBackend
  app.use('/api/media/', mediaHandler)
  app.use('/api/', tinaHandler)
  
  return app
};

Currently, there is no Next.js implementation of the SimpleMediaHandler--you might be able to integrate the Express.js code with your Next.js application, but the author of this package has not used Next.js enough to know exactly how. Contributions and examples welcome!

Credits

This package was initially created as part of tina-true-selfhosted-example.

Most of the code for this package came directly from the @tinacms/cli package.