Something the Pages team is working on improving. In the meantime (and this is not officially suppor

Something the Pages team is working on improving. In the meantime (and this is not officially supported; could break/change in the future):
  1. Create a
    wrangler.toml
    with a
    preview_database_id
    key that maps to the same name used for --d1=<BINDING> you pass to wrangler pages dev
    • e.g. "DB" or "PROD_DB" (as appropriate)
  2. Execute wrangler d1 commands with the
    --local
    flag against that local database to seed it / run migrations / etc - e.g. wrangler d1 execute db-name --file=seed.sql --local
  3. Ensure that you pass --d1=BINDING_NAME to any wrangler pages dev commands so that Pages references the same local DB.
Was this page helpful?