JSPM

  • Created
  • Published
  • Downloads 158
  • Score
    100M100P100Q79106F
  • License MIT

API client for consuming content from your repo.md projects

Package Exports

  • repo-md
  • repo-md/min

Readme

npm npm bundle size Documentation JavaScript Markdown

Repo.md 💙 JS

A lightweight JavaScript client library for fetching and working with content stored in the repo.md API. The library provides easy access to posts, media, and other content stored in your repo.md projects.

Note: This is an early preview release of our JavaScript SDK. API routes and method names might change as we extend functionalities. We look forward to seeing developers play with it!

Playground

Test the API in the repo.md API playground: https://playground.repo.md/

Installation

NPM

npm i repo-md

Use in your favourite frameworks

React Vue.js Remix Astro WordPress


Deploy apps on the edge:

Cloudflare Fly.io

CDN (Browser)

You can also include repo-md directly in your HTML via CDN:

<!-- From unpkg (recommended) -->
<script src="https://unpkg.com/repo-md"></script>

<!-- Or from jsDelivr -->
<script src="https://cdn.jsdelivr.net/npm/repo-md"></script>

<!-- Minified versions for production -->
<script src="https://unpkg.com/repo-md/repo-md.min.umd.cjs"></script>
<script src="https://cdn.jsdelivr.net/npm/repo-md/repo-md.min.umd.cjs"></script>

When loaded via CDN, the library is available as a global variable RepoMD:

<script>
  const repo = new RepoMD.RepoMD({
    projectId: "680e97604a0559a192640d2c",
  });

  // Use repo client methods
  repo.getAllPosts().then((posts) => {
    console.log(posts);
  });
</script>

UMD Module in Node.js

If you need to use the UMD module in a Node.js project that doesn't support ES modules:

// Using require with the UMD build
const RepoMD = require("repo-md/min").RepoMD;

// Initialize the client
const repo = new RepoMD({
  orgSlug: "iplanwebsites",
  projectSlug: "port1g",
  projectId: "680e97604a0559a192640d2c",
});

// Use client methods
repo.getAllPosts().then((posts) => {
  console.log(posts);
});

Docs

All details on endpoints can be found here:

https://repo.md/docs

Framework Integrations

RepoMD provides two ways to integrate with your framework:

  1. Direct Integration - Pass the project ID directly (simplest)
  2. Instance-based Integration - Use an existing RepoMD instance (more control)

Quick Examples

Vite/Vue

// vite.config.js - Direct integration (recommended)
import { viteRepoMdProxy } from 'repo-md';

export default {
  server: {
    proxy: viteRepoMdProxy('your-project-id') // One line! 🎉
  }
};

Next.js

// middleware.ts - Direct integration (recommended)
import { nextRepoMdMiddleware } from 'repo-md';

export const { middleware, config } = nextRepoMdMiddleware('your-project-id');

Remix

// app/routes/$.tsx - Direct integration (recommended)
import { remixRepoMdLoader } from 'repo-md';

export const loader = remixRepoMdLoader('your-project-id');

Cloudflare Workers

// worker.js - Direct integration (recommended)
import { cloudflareRepoMdHandler } from 'repo-md';

const handler = cloudflareRepoMdHandler('your-project-id');

export default {
  async fetch(request) {
    return handler(request);
  }
};

Using with RepoMD Instance

When you need more control or want to use other RepoMD features:

// Create a shared instance
import { RepoMD } from 'repo-md';

const repo = new RepoMD({ 
  projectId: 'your-project-id',
  debug: true
});

// Use for proxy
export default {
  server: {
    proxy: repo.createViteProxy()
  }
};

// Use the same instance for data fetching
const posts = await repo.getAllPosts();
const media = await repo.getAllMedia();

// Or use it for Remix
export const loader = repo.createRemixLoader();

Environment Variables

All integrations support environment variables:

// Checks REPO_MD_PROJECT_ID, VITE_REPO_MD_PROJECT_ID, etc.
viteRepoMdProxy() // No project ID needed if env var is set

For complete documentation and advanced examples, see the integrations guide.

Contributing

We welcome contributions to improve the repo.md client library! If you'd like to contribute, please feel free to submit a pull request. Whether it's fixing bugs, improving documentation, or adding new features, your help is appreciated.

Developing the Demo

The repo includes a demo application built with React that showcases the library's capabilities.

To run the demo locally:

npm run dev:demo

This will start the demo on http://localhost:5174.

Roadmap

Here are some planned improvements for future releases:

  • Implement more API endpoints
  • Better validation and logging with configurable debug levels
  • Improved TypeScript types
  • Enhanced playground demo
  • Python SDK
  • Command line tools
  • And more...

We're constantly working to improve the library based on developer feedback.

License

MIT