Skip to content

Use the packages without the CMS repo ​

The website-facing packages are plain TypeScript source — copy them into a standalone website workspace and drop every CMS-only dependency.

What to copy ​

text
your-site/
  packages/
    core/       # @narew/core — shared contracts (schemas, prose, validation, localized-read, binding, local manifest)
    cli/        # @narew/cli — narew-cms commands (generate, content bind/env, dev, mcp; peer-depends on wrangler)
    drizzle/    # @narew/drizzle — collection adapter, table() helper and Drizzle Kit defaults
    content/    # @narew/content — OPTIONAL: preview runtime, binding helper, reader, Hono adapter
  package.json  # your own pnpm workspace root

The copied packages sit under packages/ beside core/ — one workspace glob covers them all. Which packages a project needs depends on its role:

  • Website only — reads a registered database and renders it: copy packages/core alone. Live preview additionally takes packages/content, and packages/cli supplies content env and the dev command (narew-cms dev).
  • Content-owning project — owns the Drizzle schema, narew.config.ts and the migration history: copy packages/core, packages/cli and packages/drizzle; narew-cms generate and content bind (--from-file or individual flags) run here.
  • Combined content + website workspace: everything above, with packages/content optional until preview is enabled.

Copy the source trees only — never node_modules, test fixtures (*.fixture.ts), testing directories (src/testing/), the CMS applications, or the repository root configs. git archive from a reviewed narew-cms commit into a new, empty folder is one valid way; move the site/* sources under packages/ afterwards:

sh
git archive HEAD packages/core site/cli site/drizzle site/content | tar -x -C .
mkdir -p packages
mv site/cli site/drizzle site/content packages/
rmdir site

Drop site/content from the archive and the move when not using preview.

Standalone workspace ​

pnpm-workspace.yaml lists the copied directories:

yaml
packages:
    - "packages/*"

Cross-package references inside the copies already use workspace:*, so your root package.json can depend on the workspace exactly like the monorepo — without requiring @narew/content unless you opted into it:

json
{
	"name": "your-site",
	"version": "0.0.0",
	"private": true,
	"type": "module",
	"dependencies": {
		"@narew/core": "workspace:*"
	},
	"devDependencies": {
		"@narew/cli": "workspace:*",
		"@narew/drizzle": "workspace:*",
		"drizzle-kit": "0.31.11",
		"drizzle-orm": "0.45.4",
		"typescript": "7.0.2",
		"wrangler": "^4.0.0"
	}
}

Run pnpm install at the workspace root, then run project commands such as pnpm exec narew-cms generate from your content project directory. Note that @narew/cli declares wrangler as a peer dependency, so your host workspace supplies it in devDependencies as shown above.

To use preview, additionally copy the content package under packages/ and add "@narew/content": "workspace:*" to the website's dependencies. The base manifest above stays content-free otherwise. Modular exports allow sites to opt into only what they need:

  • @narew/content/binding provides lightweight signed binding verification without pulling Durable Objects or preview runtime code.
  • @narew/content/read provides the versioned, KV-cached raw-SQL reader with zero DO overhead.
  • @narew/content/kysely requires kysely as an optional peer dependency.
  • @narew/content/hono requires hono as an optional peer dependency (type-only at runtime).

Core modularity and lightweight runtime: @narew/core sets "sideEffects": false and exposes 10 targeted subpaths: ., ./prose, ./validation (which includes media schemas), ./defaults, ./content-binding, ./content-cache, ./content-session (including session inputs), ./storage, ./localization, and ./localized-read. Former subpaths @narew/core/website, @narew/core/media, and @narew/core/content-session-input are retired. For localized sites, import @narew/core/localized-read for fast locale fallback selection without pulling heavy CMS dictionary parsers or validation logic into your worker.

Pinned toolchain: Node 24 (>= 24.11), pnpm 11.23, TypeScript 7, drizzle-orm 0.45.4, drizzle-kit 0.31.11 — match these versions rather than floating. @narew/core is required for the Narew contracts and tooling; its runtime helpers (prose rendering, validation) are optional to call. See Website data access and Preview your website for usage.