MCPcopy Create free account
hub / github.com/JaleelB/readium-x

github.com/JaleelB/readium-x @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
335 symbols 1,039 edges 165 files ⚖ MIT 0 documented · 0% ● updated 51d ago★ 521 open issues

Browse by type

⨍ Functions 296◇ Types & classes 39
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ReadiumX

Twitter Follow GitHub Repo stars

https://github.com/user-attachments/assets/1c3a5138-0fc7-43e9-b0a2-761e70f9c83c

ReadiumX

The open-source tool that provides access to premium Medium articles without the paywall



<a href="https://readiumx.com"><strong>Learn more »</strong></a>






<a href="#introduction"><strong>Introduction</strong></a> ·
<a href="#features"><strong>Features</strong></a> ·
<a href="#tech-stack"><strong>Tech Stack</strong></a> ·
<a href="#contributing"><strong>Contributing</strong></a>

Introduction

ReadiumX is an open source tool that provides access to premium Medium articles without the paywall, allowing you to bookmark, and manage your reading experience across any device

Tech Stack

Features

  • Access Premium Articles: Bypass paywalls to access content freely.
  • Bookmarking System: Save your favorite articles for later reading.
  • Progress Tracking: Automatically saves your reading progress to resume where you left off.
  • Reading History Management: View and manage your reading history with options to delete records.

Running Locally

  1. Clone the repository

bash git clone https://github.com/JaleelB/readium-x.git

  1. Install dependencies using pnpm

bash pnpm install

  1. Copy the .env.example to .env.local and update the variables.

bash cp .env.example .env.local

  1. Start the normal Next.js development server

bash pnpm run dev

This runs at http://localhost:3156. In this mode, Cloudflare bindings are simulated through OpenNext's local dev bridge when available. If the READIUMX_ARTICLE_CACHE binding is not available, scraping still works; it simply skips the server-side KV cache and uses the existing client session cache.

  1. Push the database schema

bash pnpm run db:push

  1. To test the app in the Cloudflare Workers runtime locally, copy .dev.vars.example to .dev.vars, fill in the values, then run:

bash cp .dev.vars.example .dev.vars pnpm preview

pnpm preview builds the OpenNext worker and starts Wrangler, usually at http://localhost:8787. This is the mode to use when you specifically want to verify the Cloudflare KV cache behavior before deployment.

Cloudflare Deployment

ReadiumX deploys to Cloudflare Workers through OpenNext.

  1. Create separate remote KV namespaces for production and preview:

bash pnpm wrangler kv namespace create readiumx-article-cache pnpm wrangler kv namespace create readiumx-article-cache-preview

These commands create the real Cloudflare KV namespaces. They require wrangler login locally or CLOUDFLARE_API_TOKEN in CI. For day-to-day pnpm dev, you do not need to run them first; they are required before deploying or testing against real Cloudflare resources.

  1. Put the generated namespace IDs into wrangler.jsonc for the READIUMX_ARTICLE_CACHE binding. Keep the production namespace as id and the preview namespace as preview_id. If Wrangler offers to add the binding for you, use READIUMX_ARTICLE_CACHE as the binding name; the app does not read lowercase binding names.

  2. Add the application variables and secrets from .dev.vars.example to Cloudflare Workers.

  3. Add these GitHub repository secrets for deployment:

  4. CLOUDFLARE_ACCOUNT_ID
  5. CLOUDFLARE_API_TOKEN

  6. Preview or deploy:

bash pnpm preview pnpm deploy

OpenNext incremental cache and public document cache

open-next.config.ts uses OpenNext's KV incremental cache instead of the dummy adapter. wrangler.jsonc binds NEXT_INC_CACHE_KV to the same production and preview namespace IDs as READIUMX_ARTICLE_CACHE; no new namespace is needed. If managing bindings in the dashboard, add a KV namespace binding named NEXT_INC_CACHE_KV to the existing article-cache namespace before the next approved deployment. Keep both bindings aligned if changing namespace IDs. OpenNext uses build-scoped keys; extracted articles use article:v1:*. The OpenNext deploy command populates prerendered cache entries automatically.

KV is eventually consistent and shares the existing namespace's quotas. This is appropriate for the current public shells; it does not cache authenticated SSR article/account responses. No ISR queue or tag cache is added: the current revalidatePath calls concern dynamic protected pages. Adding cached data or ISR with time-based/on-demand revalidation later requires the corresponding queue/tag-cache setup described in the OpenNext caching documentation.

The Worker also caches plain cookieless GET documents for /, /signin, /signup, /forgot-password, and /reset-password for one hour at each Cloudflare location, with separate keys for each host and path. Queries, any Cookie or Authorization header, RSC/navigation requests, prefetches, server actions, redirects, errors, Set-Cookie responses, and non-HTML responses bypass this cache. Auth callbacks and protected pages are excluded. Responses vary on Cookie and Authorization so browsers re-enter Clerk after sign-in. x-readium-cache: hit|miss identifies eligible responses. The edge cache is independent of OpenNext's incremental cache; purge the zone cache after a release if these public shells must update before their one-hour TTL expires.

Anonymous /article and /article/* requests redirect to /signin before OpenNext loads. Clerk cookies (including suffixed names), bearer credentials, and Clerk handshake queries still reach the unchanged middleware for actual session validation. Cookie presence never grants article access.

Scanner requests still count as Worker invocations when answered here, but avoid Next/Clerk CPU. To stop matching requests before the Worker, optionally add a zone WAF custom rule that blocks known scanner paths such as /wp-*, /.env, /.git, /admin, and PHP endpoints. Check Security Events and test normal sign-in, callbacks, article reading, and the Clerk webhook first. Bot Fight Mode is another optional zone setting: monitor its challenges carefully because WAF Skip rules cannot exempt traffic from Bot Fight Mode. These dashboard changes are manual suggestions, not part of this PR's deployment.

Worker CPU and Clerk

Public files in public/ (robots.txt, sitemap.xml, manifests) are served by Workers Static Assets because wrangler.jsonc sets assets.run_worker_first to false. Leave that false. worker.ts is a second line of defense for those paths, and it 404s scanner probes (.php, .env, wp-login, …) before Next.js or Clerk load. It does not block crawlers by User-Agent.

Clerk stays installed. Middleware only runs on auth, account, article, bookmark, and history routes. The homepage does not call auth(), so anonymous and crawler traffic does not enter the handshake flow.

Production Clerk keys cannot be set from this repo. In the Cloudflare Worker secrets for readiumx.com, set:

  • CLERK_SECRET_KEY to a live key (sk_live_...)
  • NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY to the matching live key (pk_live_...)

Clerk decides development vs production from the publishable key: anything other than pk_live_ is a development instance. Cookieless document GETs then redirect into the handshake, and a failed handshake token throws from handleTokenVerificationErrorInDevelopment (HTTP 500) on every route that still runs middleware (/signin, /account, …). sk_test_ paired with pk_live_ is also wrong — signature checks fail. The worker logs a warning when the production host is using non-live keys. Redeploy after changing NEXT_PUBLIC_* values so the client bundle picks them up; Worker secrets alone do not rewrite the already-built client script.

There is no HTTP→HTTPS or www→apex redirect in the app. Both readiumx.com and www.readiumx.com are attached as Worker custom domains, so each host invokes the Worker once. Cloudflare's "Always Use HTTPS" runs before the Worker and does not double-execute it. If you want a single host, add a Cloudflare Redirect Rule (Bulk Redirects or Single Redirects), not a redirect inside middleware — a middleware redirect spends Worker CPU twice.

Optional follow-up, not required for this fix: remove Clerk only if accounts, bookmarks, and history are going away. The app still uses it for sign-in, protected pages, and the Clerk webhook.

Setting up Google Provider

If you want google login, you'll need to setup a google project and create some keys:

  1. https://console.cloud.google.com/apis/credentials
  2. create a new project
  3. setup oauth consent screen
  4. create credentials - oauth client id
  5. for authorized javascript origins

  6. http://localhost:3000

  7. https://your-domain.com

  8. Authorized redirect URIs

  9. http://localhost:3000/api/login/google/callback

  10. https://your-domain.com/api/login/google/callback

  11. Set your google id and secret inside of .env

  12. GOOGLE_CLIENT_ID

  13. GOOGLE_CLIENT_SECRET

Setting up Github Provider

If you want github login, you'll need to setup a github project and create some keys:

  1. https://github.com/settings/developers
  2. Create a new OAuth App
  3. Create an application for the for local development:
  4. Homepage URL: http://localhost:3000
  5. Authorization callback URL: http://localhost:3000/api/login/github/callback
  6. Create an application for the for production:
  7. Homepage URL: https://your-domain.com
  8. Authorization callback URL: https://your-domain.com/api/login/github/callback

Contributing

Contributions are welcome! Please open an issue if you have any questions or suggestions. Your contributions will be acknowledged. See the contributing guide for more information.

License

Licensed under the MIT License. Check the LICENSE file for details.

Extension points exported contracts — how you extend this code

browse all types & interfaces →

Core symbols most depended-on inside this repo

browse all functions →

Shape

Function 273
Method 23
Interface 21
Class 18

Languages

TypeScript100%

Modules by API surface

use-cases/errors.ts18 symbols
stores/article-store.ts15 symbols
lib/tts.ts13 symbols
components/article-toolbar-options.tsx13 symbols
lib/parser.ts12 symbols
lib/article-cache.ts9 symbols
hooks/use-bookmarks-query.ts9 symbols
lib/utils.ts8 symbols
use-cases/article.ts7 symbols
data-access/article.ts7 symbols
app/history/history-list.tsx7 symbols
hooks/use-reading-progress-sync.ts6 symbols

For agents

$ claude mcp add readium-x \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page