From your terminal:
npm run dev
This starts your app in development mode, rebuilding assets on file changes.
npx wrangler d1 create d1-northwind
npx wrangler d1 create d1-northwind-staging
Get the output database id and add it to wrangler.toml
npx wrangler d1 execute d1-northwind --file db/schema.sql
npx wrangler d1 execute d1-northwind --file db/data.sql
npx wrangler dev --local --persist --env local --assets local-assets --ip 0.0.0.0
Wrangler will persist a local SQLite compatible sql file which you can access to with other clients:
sqlite3 .wrangler/state/d1/DB.sqlite3
.tables
Wire it up via the CF Dashboard. More info to come.
- Create a github repo
git remote add origin https://github.com/yourgithubusername/githubrepo
$ git branch -M main
git push -u origin main
-
Connect your github repo to your Cloudflare pages. If it's already connected, you should be able to select your repo on Cloudflare pages
-
Configure your environment variables in Settings > Environment Variables
- CF_PAGES: production
- SESSION_SECRET:
-
Configure your D1 binding in Settings > Functions
- Name of variable/binding: DB, Select your production db in the dropdown (Example: d1-northwind)