tweaktags

TweakTags example, Next.js app

This small app shows TweakTags working end to end with Next.js and Postgres.

What it shows

Run it

These steps assume you run them from a WSL terminal where Node and pnpm work natively.

  1. Start a local Postgres, for example with Docker:

    docker run --name tweaktags-pg -e POSTGRES_USER=tweaktags -e POSTGRES_PASSWORD=tweaktags \
      -e POSTGRES_DB=tweaktags -p 5432:5432 -d postgres:16
    
  2. From the repo root, install and build the packages:

    pnpm install
    pnpm build
    
  3. Set the environment variables for this app. Copy .env.example to .env and adjust if needed:

    cp examples/next-app/.env.example examples/next-app/.env
    
  4. Create the tables and a superuser, using the config in this folder:

    cd examples/next-app
    pnpm tweaktags migrate
    pnpm tweaktags create-superuser --email you@example.com --password supersecret
    
  5. Start the app:

    pnpm dev
    
  6. Open the app, sign in with the edit bar in the corner, click “Edit page”, change any of the three editable spots, then click away to save. Reload the page to confirm the change was stored in the database.

Checking the database

You can confirm the saved rows directly:

docker exec -it tweaktags-pg psql -U tweaktags -d tweaktags -c 'SELECT tag, body FROM "__TweakTags__Content";'