Overview
In this tutorial we'll walk through building a simple, web‑based manga reader using vanilla JavaScript, HTML, and CSS. The app will fetch manga chapters from a public API, display pages, and allow navigation between chapters.
1. Set Up Your Project
Create a folder called manga-reader and add the following files:
index.html
reader.html
chapter.html
app.js
styles.css
Link app.js and styles.css in your index.html:
<link rel="stylesheet" href="styles.css">
<script src="app.js" defer></script>
2. Design the Layout
Our reader will consist of three main parts:
- Navbar – consistent across all pages.
- Content area – displays manga pages.
- Footer – static footer with copyright.
Use semantic tags for accessibility:
<header></header>
<nav></nav>
<main></main>
<footer></footer>
3. Fetch Manga from an API
We’ll use the MangaDex API as an example. First, fetch a list of chapters:
fetch('https://api.mangadex.org/chapter?manga=YOUR_MANGA_ID')
.then(res => res.json())
.then(data => console.log(data));
Replace YOUR_MANGA_ID with the ID of your chosen manga.
4. Render Pages
Each chapter contains an array of page URLs. Create a simple gallery:
const container = document.getElementById('page-gallery');
data.data.forEach(page => {
const img = document.createElement('img');
img.src = page.attributes.fileUrl;
img.alt = `Page ${page.attributes.pageNumber}`;
container.appendChild(img);
});
Wrap this logic in a function and call it when the reader page loads.
6. Deploy Your App
Use GitHub Pages, Netlify, or Vercel to host your static files. Ensure all relative paths point correctly. For example, on GitHub Pages the base URL may need to be updated with a baseurl tag in index.html.