Read more »


IndexedDB Note App

📝 Simple Note App (IndexedDB)


 

1. Introduction

In this tutorial, we will learn how to turn a Blogspot page into a simple web app by:

  • Embedding HTML and JavaScript directly into a blog post
  • Using IndexedDB to store data locally in the browser (no backend required)

We will build a simple example: a Note-Taking Web App.


2. What is IndexedDB?

IndexedDB is a built-in browser database that allows you to store structured data locally.

Key features:

  • Stores large amounts of data
  • Supports object-based storage (like JSON)
  • Works offline
  • More powerful than localStorage

Common use cases:

  • Note apps
  • Todo lists
  • Offline web applications

3. How to Embed a Web App in Blogspot

To run a web app inside Blogspot:

  1. Go to New Post
  2. Switch to HTML view
  3. Paste your full HTML + JavaScript code into the editor

4. Example Web App (Note App using IndexedDB)

You can copy and paste this directly into a Blogspot post:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>IndexedDB Note App</title>
<style>
body { font-family: Arial; padding: 20px; }
input, button { padding: 10px; margin: 5px; }
.note { padding: 10px; border: 1px solid #ccc; margin-top: 5px; }
</style>
</head>
<body>

<h2>📝 Simple Note App (IndexedDB)</h2>

<input id="noteInput" placeholder="Write a note...">
<button onclick="addNote()">Add</button>

<div id="list"></div>

<script>
let db;

// Open database
const request = indexedDB.open("NoteDB", 1);

request.onupgradeneeded = function(e) {
db = e.target.result;
db.createObjectStore("notes", { keyPath: "id", autoIncrement: true });
};

request.onsuccess = function(e) {
db = e.target.result;
loadNotes();
};

// Add note
function addNote() {
const text = document.getElementById("noteInput").value;
if (!text) return;

const tx = db.transaction("notes", "readwrite");
const store = tx.objectStore("notes");

store.add({ text: text });

tx.oncomplete = () => {
document.getElementById("noteInput").value = "";
loadNotes();
};
}

// Load notes
function loadNotes() {
const list = document.getElementById("list");
list.innerHTML = "";

const tx = db.transaction("notes", "readonly");
const store = tx.objectStore("notes");

store.openCursor().onsuccess = function(e) {
const cursor = e.target.result;
if (cursor) {
const div = document.createElement("div");
div.className = "note";
div.innerHTML = cursor.value.text;
list.appendChild(div);
cursor.continue();
}
};
}
</script>

</body>
</html>

5. How It Works

The app is built with three main parts:

1. Create Database

indexedDB.open("NoteDB", 1);

2. Store Data

store.add({ text: text });

3. Read Data

store.openCursor();

6. Important Notes for Blogspot

  • Some themes may block <script> execution
  • Avoid using heavy external libraries
  • IndexedDB data is stored locally in the user's browser only

7. Possible Improvements

You can upgrade this simple app into:

  • Todo list with checkboxes
  • Editable & deletable notes
  • File/image storage using Blob in IndexedDB
  • PWA (Progressive Web App) version

8. Conclusion

With just HTML, JavaScript, and IndexedDB, you can turn a Blogspot page into a fully working offline web app without any backend.