The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Build a micro-journal app

Creating a micro-journal app involves building a simple application where users can quickly jot down short journal entries, save them, and optionally view or delete past entries. Below is a step-by-step guide and an example of a basic micro-journal app using React for the frontend and localStorage for persistent data storage, so no backend is required.


Features

  • Add short journal entries

  • View all entries in a list

  • Delete entries

  • Entries saved in browser localStorage to persist data between sessions


Step 1: Set up React App

If you want to build it locally, create a React app:

bash
npx create-react-app micro-journal cd micro-journal npm start

Step 2: Micro-Journal App Code

jsx
import React, { useState, useEffect } from 'react'; function MicroJournal() { const [entry, setEntry] = useState(''); const [entries, setEntries] = useState([]); // Load entries from localStorage on mount useEffect(() => { const savedEntries = JSON.parse(localStorage.getItem('microJournalEntries')) || []; setEntries(savedEntries); }, []); // Save entries to localStorage when entries change useEffect(() => { localStorage.setItem('microJournalEntries', JSON.stringify(entries)); }, [entries]); const handleAddEntry = () => { if (entry.trim() === '') return; const newEntry = { id: Date.now(), text: entry.trim(), date: new Date().toLocaleString() }; setEntries([newEntry, ...entries]); setEntry(''); }; const handleDeleteEntry = (id) => { const filteredEntries = entries.filter(e => e.id !== id); setEntries(filteredEntries); }; return ( <div style={{ maxWidth: 600, margin: '2rem auto', padding: 20, fontFamily: 'Arial, sans-serif' }}> <h2>Micro Journal</h2> <textarea rows={3} placeholder="Write a quick journal entry..." value={entry} onChange={(e) => setEntry(e.target.value)} style={{ width: '100%', padding: 10, fontSize: 16, borderRadius: 5 }} /> <button onClick={handleAddEntry} style={{ marginTop: 10, padding: '10px 20px', fontSize: 16, cursor: 'pointer', borderRadius: 5, backgroundColor: '#007bff', color: '#fff', border: 'none' }} > Add Entry </button> <div style={{ marginTop: 30 }}> {entries.length === 0 && <p>No entries yet.</p>} {entries.map(({ id, text, date }) => ( <div key={id} style={{ background: '#f9f9f9', padding: 15, marginBottom: 15, borderRadius: 5, position: 'relative' }} > <small style={{ color: '#555' }}>{date}</small> <p style={{ marginTop: 5, whiteSpace: 'pre-wrap' }}>{text}</p> <button onClick={() => handleDeleteEntry(id)} style={{ position: 'absolute', top: 10, right: 10, background: 'transparent', border: 'none', color: '#d00', fontWeight: 'bold', cursor: 'pointer', fontSize: 18 }} aria-label="Delete entry" title="Delete entry" > &times; </button> </div> ))} </div> </div> ); } export default MicroJournal;

Explanation:

  • State management:
    entry holds the current text input.
    entries is an array of journal objects {id, text, date}.

  • localStorage:
    On component mount (useEffect), existing entries are loaded.
    On entries update, the list is saved back.

  • Add Entry:
    Adds a new journal item with a timestamp, prepended to the list.

  • Delete Entry:
    Removes an entry from the list by filtering out its id.


How to use:

  • Type your quick thought or note into the textarea.

  • Click “Add Entry” to save it.

  • View your previous entries listed below.

  • Delete entries with the red “×” button.


This app can be enhanced by adding features like syncing with a backend, editing entries, tagging, or search, but this is a minimal micro-journal app that works entirely in-browser. If you’d like, I can help build a version with backend or mobile support too!

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About