react-readit
v0.1.6
Published
Tiny utility to fetch GitHub README/MD as raw text (framework-agnostic).
Maintainers
Readme
🚀 Usage
import { parse, get } from "react-readit";
// 1️⃣ Parse GitHub URL
const info = parse("https://github.com/HanJunSeoJB/frontend");
// → { owner: "HanJunSeoJB", repo: "frontend" }
// 2️⃣ Fetch raw README
const md = await get({ input: "HanJunSeoJB/frontend", ref: "main" });
console.log(md.slice(0, 200)); // Markdown text
// 3️⃣ Fetch a specific Markdown file
const doc = await get({
input: "HanJunSeoJB/frontend",
path: "docs/guide.md",
ref: "dev",
});🧩 API
parse(url: string): Parsed
Parses a GitHub URL or "owner/repo" string.
Returns:
type Parsed = {
owner: string;
repo: string;
ref?: string;
path?: string;
};Examples:
parse("https://github.com/user/project");
// { owner: "user", repo: "project" }
parse("user/project");
// { owner: "user", repo: "project" }
parse("https://github.com/user/project/blob/main/docs/intro.md");
// { owner: "user", repo: "project", ref: "main", path: "docs/intro.md" }get(options: GetOptions): Promise<string>
Fetches raw markdown text from a repository’s README or a specific file.
type GetOptions = {
input: string; // e.g. "owner/repo" or full GitHub URL
ref?: string; // branch/tag/commit
path?: string; // path to a .md file
};Examples:
// README (default)
await get({ input: "user/project" });
// Specific branch
await get({ input: "user/project", ref: "main" });
// Specific file
await get({ input: "user/project", path: "docs/guide.md" });💡 Notes
- Works with public repositories only.
- Requires Node.js v18+ (built-in
fetch). - No framework dependency (works in Node, Deno, or browser).
- If you need React rendering, use
react-markdownon the returned text.
📄 License
MIT © 2025 Han Junseo
