### Quickstart FlipBook example with Page and ref Source: https://github.com/benhonda/openpageflip/blob/main/packages/react/README.md Quickstart component showing FlipBook with Page children, a ref to the core Book, and buttons calling flipPrev/flipNext. Uses size="stretch" and cover; runs in the docs site's test suite. ```tsx import "@openpageflip/core/styles.css"; import { type Book, FlipBook, Page } from "@openpageflip/react"; import { useRef } from "react"; export default function Quickstart() { const book = useRef(null); return ( <>

OpenPageFlip

A page-turn effect for React

Every child is a page

Wrap one in Page to make it hard, or to put a class or style on the page element itself.

No refs on pages

The book owns the page elements. Your components render inside them.

Props are options

Change one and the book is rebuilt on the same page. Children can change whenever.

Renders on the server

This page was server-rendered by the docs site and hydrated after.

The end

); } ``` -------------------------------- ### Install @openpageflip/core and @openpageflip/react Source: https://github.com/benhonda/openpageflip/blob/main/packages/react/README.md Install the core and React packages with bun. Requires bun as the package manager. ```sh bun add @openpageflip/core @openpageflip/react ``` -------------------------------- ### Install @openpageflip/core with bun Source: https://github.com/benhonda/openpageflip/blob/main/packages/core/README.md Install the package using the bun package manager. ```sh bun add @openpageflip/core ``` -------------------------------- ### TypeScript quickstart: createBook Source: https://github.com/benhonda/openpageflip/blob/main/packages/core/README.md Imports the core styles and createBook function, then exports a mount function that creates a Book instance with specified dimensions and options. The container's children are the pages in reading order. ```ts import "@openpageflip/core/styles.css"; import { type Book, createBook } from "@openpageflip/core"; /** The container's children are the pages, in reading order. */ export function mount(container: HTMLElement): Book { return createBook(container, { width: 400, // base page size; with size "stretch" only the ratio matters height: 560, size: "stretch", // scale to the container, portrait when it gets narrow cover: true, // first and last pages stand alone }); } ``` -------------------------------- ### Prompt to read OpenPageFlip docs before coding Source: https://github.com/benhonda/openpageflip/blob/main/apps/docs/src/content/docs/start/agents.mdx Paste this prompt before your request to instruct the AI assistant to read the OpenPageFlip guides before writing any code. It emphasizes that the API is different from similar libraries. ```text Read https://openpageflip.dev/guides/ before writing any code that uses OpenPageFlip. Follow those docs rather than what you know about PageFlip or stPageFlip; the API is different. ``` -------------------------------- ### llms.txt URL for docs-URL tools Source: https://github.com/benhonda/openpageflip/blob/main/apps/docs/src/content/docs/start/agents.mdx Paste this URL into tools with a docs-URL setting (like Cursor) to point them to the llms.txt index, which links to the guides and full API reference. ```text https://openpageflip.dev/llms.txt ``` -------------------------------- ### AGENTS.md instructions for AI assistants Source: https://github.com/benhonda/openpageflip/blob/main/apps/docs/src/content/docs/start/agents.mdx Place this content in your agent's instructions file (e.g., CLAUDE.md, AGENTS.md, .github/copilot-instructions.md, or a Cursor rule) so the assistant reads it at session start. It tells the assistant that OpenPageFlip is not PageFlip or stPageFlip and to read the docs before writing code. ```md ## OpenPageFlip Page-flip effect for HTML content: `@openpageflip/core` (plain JavaScript) and `@openpageflip/react` (React 19). It is not PageFlip or stPageFlip: the API is different, so read the docs before writing code. - Guides and examples: https://openpageflip.dev/guides/ - Everything, API reference included: https://openpageflip.dev/llms.txt ``` -------------------------------- ### CDN script tag for OpenPageFlip Source: https://github.com/benhonda/openpageflip/blob/main/apps/docs/src/content/docs/start/core.mdx Loads the core package from a CDN and creates a book instance with a container element and options. The script tag puts createBook on window.OpenPageFlip. ```html ``` -------------------------------- ### HTML container with pages and hard covers Source: https://github.com/benhonda/openpageflip/blob/main/packages/core/README.md Defines the book container with page elements. The data-density="hard" attribute makes a page rigid, as used for covers. ```html

OpenPageFlip

A page-turn effect for the web

Drag an edge

Hover the outer edge and it furls. Take hold and pull: let go past the middle and the page turns; let go early and it settles back.

Or just click

Click a page's outer edge and it turns. The middle is yours: text selects, links open. On a touch screen, a swipe anywhere turns the page.

Hard and soft

Covers are hard, so they swing as one stiff sheet. Inner pages bend along the fold, the way paper does.

Any HTML

Pages are ordinary elements. Text, images, forms, video - whatever a page holds keeps working.

The end

``` -------------------------------- ### Pages container with hard density Source: https://github.com/benhonda/openpageflip/blob/main/apps/docs/src/content/docs/start/core.mdx Shows the container structure with pages as elements. Any element can be a page; data-density="hard" makes a page turn as a stiff sheet. ```html
Cover
Page 1
Page 2
Page 3
Back cover
```