How to Build a Notion-Style Notes App with AI
Build a Notion-style notes app in Layerwise. Define the page record, choose local saving or account sync, plan search and Trash, test, and publish.
Table of contents
A notes app looks small: a sidebar, an editor, and a search box. The decisions that shape it are less visible. What does a page store when it holds to-dos, toggles, and images? Where is it saved while you type? What happens when the same page changes on a laptop and a phone? Can a deleted page come back? Answer those before asking an AI to write code, and the first version is much easier to test.
This guide builds a Notion-style notes web app with Layerwise: pages nest inside pages, and each page is a stack of blocks you add from a / menu. You will define the page record, choose how pages are saved, plan search and deletion, start from the NoteNest template or a prompt, test, and publish.

1. Define the page record
Every feature in a notes app reads or writes the same record, so write it down first. This is the page type in NoteNest, without its display settings such as font and full width:
type Page = {
id: string; // created on the device with crypto.randomUUID()
parentId: string | null; // null puts the page at the top of the sidebar
title: string;
icon: string | null; // an emoji
cover: string | null; // a built-in gradient or an image URL
content: string; // the editor document as JSON
favorite: boolean;
position: number; // order among pages with the same parent
createdAt: number; // milliseconds since 1970
updatedAt: number; // changes on every edit
deletedAt: number | null; // set when the page moves to Trash
purged: boolean; // set by Delete forever
};A few fields matter more than they look. The id is generated on the device, so a page exists before any server knows about it. parentId and position are the whole page tree: dragging a page in the sidebar changes only those two fields. updatedAt is how two copies of a page are compared during sync. deletedAt and purged turn deletion into a change of state, which allows recovery and keeps a deleted page from returning from another device.
The body is the editor's JSON document. Markdown has no place for a callout's icon, a block's color, an image's width, or a mention that follows a page when it is renamed, and NoteNest's editor, Tiptap, reads and writes this JSON directly. Markdown still helps at the edges: you can type Markdown shortcuts, paste Markdown, and export any page as a .md file.
Notice what the record leaves out. Backlinks and a page's table of contents are worked out from page content each time they are shown. Because nothing is stored twice, sync only has to move pages, and a backlink can't drift out of step with the link that creates it.
2. Decide where pages are saved
There are three reasonable models:
- Local only. Pages stay in the browser's storage. No account is needed, but clearing site data or switching devices loses access.
- Account only. Pages live in the project database and follow the user, but saving requires a connection and sign-in.
- Local first, with optional sync. Pages save on the device as you type. Signing in merges them with the account's copy.
NoteNest uses the third model. Signed out, pages are saved in the browser's IndexedDB and the sidebar footer reads Sign in to sync. After sign-in, NoteNest merges the device's pages with the account's, then sends changed pages shortly after each edit. It also checks the account every 30 seconds and when the window regains focus. Synced pages are stored per user in the project's built-in database, sign-in uses the project's authentication, and uploaded images and files go to the project's Storage.
The harder question is conflicts. NoteNest compares whole pages by updatedAt, as recorded by each device's clock, and keeps the newer one. If the same page is edited on two devices before they sync, the older edit is lost. For personal notes that may be acceptable. If it isn't, decide now, because the fix changes the data model. Turn on Plan mode, described in Direct the agent, to review the approach before code changes:
Explain how page sync resolves conflicts today. Then propose a change: when a
page was edited on another device since this device last synced it, keep both
versions, save the incoming one as a page titled "<title> (conflict)" next to
it in the sidebar, and show a short notice. Keep automatic local saving for
signed-out users.Two people typing in the same page at once is a different design. Edits have to be merged as they happen, usually with a library such as Yjs, and a server has to relay them live. Plan for that only if your app needs it.
3. Plan search and deletion
Press ⌘K in NoteNest to search titles and page text on the device as you type, ignoring case. With an empty search box, it lists the pages you opened recently. That works because every page is already in the browser. Each sync check downloads all of the account's pages, while edits upload only the pages that changed, up to 100 per request. A page can hold up to 1,000,000 characters, and uploaded images count as links. For a much larger workspace, ask for incremental sync that downloads only pages changed since the last check, and for server-side search.
Deletion is soft. Move to Trash sets deletedAt on a page and its sub-pages and shows Moved to Trash with an Undo button. Restore in Trash clears it and returns the page to its parent, or to the top of the sidebar if the parent is gone. Delete forever and Empty Trash clear the title and content but keep the record with purged set, so a device that still has a copy deletes it on its next sync. Without that record, a page removed on one device would come back from another. Keep it if you add automatic cleanup:
Delete pages that have been in Trash for 30 days, using the same purge as
Delete forever so other devices don't restore them. Show "Pages in Trash are
deleted after 30 days" at the top of Trash.4. Choose a starting point
Download Layerwise, sign in, and select a team.
NoteNest is a Notion-style notes app template. It has a sidebar of nested pages you can drag to rearrange, a block editor with a / menu and Markdown shortcuts, toggles, callouts, tables, columns, code, images, video, embeds, ⌘K search, page templates, and Trash. To start from it, open NoteNest, choose Use this template, pick a team and project name in Layerwise, then choose Copy to Layerwise. The page record, local saving, account sync, and uploads are already implemented, so your work is adapting them. Other workflows are in the template gallery.

To start from scratch, enter a description in Describe the app you want to build... on the team home page, including the decisions above:
Build a Notion-style notes app. Pages nest inside other pages in a sidebar
that can be reordered by dragging. Each page has a title, an emoji icon, an
optional cover, and a body of blocks: text, headings, to-dos, lists, toggles,
quotes, callouts, code, tables, and images, added from a / menu or with
Markdown shortcuts. Store each page's body as editor JSON with created,
updated, and deleted times, and keep deleted pages in Trash. Save pages in the
browser automatically while signed out. After email sign-in, sync pages to the
project database and keep the most recently updated copy of each page.
Include search across titles and page text, and a layout that works on a
phone.A blank start lets you choose each behavior, but you must verify each one yourself. The prompting guide explains how to describe users, data, and screens.
5. Test with two browsers and two accounts
Once the local preview loads, choose Start writing, then New page, and test while signed out. Type / to add a to-do list, a toggle, and a callout, drag the callout to the top by its ⋮⋮ handle, and refresh. The page and its blocks should still be there. Then type /page to add a sub-page. It should appear under the first page in the sidebar and in the breadcrumb.
Next, open the preview in your default browser from the preview header. That browser has separate storage, so pages saved only on the device should not appear there. Sign in with the same account in both windows. Your pages should appear in both, the sidebar footer should read Synced, and an edit in one window should reach the other within about 30 seconds, or sooner when you switch windows. If you changed the conflict rule, edit one page in both windows in quick succession and confirm the result.
Then sign up as a second user and confirm none of the first user's pages appear. You can also create test accounts with Add user in Authentication. Open Database, select Local, and check that each row in the synced_note table belongs to the right user. While signed in, add an image to a page and confirm the file appears in Storage. The preview and the published app share one Storage, so give test files clear names and delete them afterward. Finally, move a page to Trash in one window, restore it in the other, and check phone width.
If a check fails, open the preview console from Preview actions, or find the failed sync request in Logs. If the console shows an error you don't recognize, look it up in the vibe coding errors reference.
6. Publish and improve it
Choose Publish in the preview header, then Publish in the menu, and open the live URL when the release finishes. Local and Online use separate databases, so test pages and accounts are not copied. Repeat the sync checks on a real laptop and phone signed in to one account. The publishing guide covers release status.
Choose the next change from what you observe. Analytics shows pageviews and visitors; it never sees what anyone writes. If the sidebar footer shows Offline · changes saved here, select Online in Logs and find the failing request. Each page can already be saved as a .md file with Export as Markdown in the page menu. Exporting the whole workspace is a small, useful next step:
Add Export all pages to the workspace menu. It downloads every page not in
Trash as a zip of .md files named after their titles, with sub-pages in a
folder named after their parent page. Add Import that accepts that zip and
recreates the page tree inside a new page.Start from NoteNest if its nested pages and block editor fit how you write, or from a prompt if you need a different model. Either way, settle saving, conflicts, and deletion before adding features. For the full project workflow, follow the Quick start.