Bookmarks, Highlights & Notes
18 min read
Create and Toggle Bookmarks
Create and Toggle Bookmarks
Task
Add a user-scoped Bookmark API and connect the Reader bookmark control.
Route
Create:
app/api/books/[bookId]/bookmarks/route.ts
Store the EPUB CFI for the bookmarked location.
Create or remove the bookmark through an authenticated mutation. Always scope it with userId and bookId.
The Reader button should toggle its active state after the mutation succeeds.
Show the existing bottom-right success toast after a successful action.
Test
At a reading position:
- add a bookmark
- reload
- remove the bookmark
- verify the database state
Try another user’s Book ID.
Checkpoint
The Reader can create and remove persistent bookmarks for the current user.