This starter was initially created with C3 (Create Cloudflare CLI), and then enhanced with a few things:
npm start
to start a local dev environment (same as npm run dev
)mkcert
The initial project was created with:
npm create cloudflare@latest cf-svelte -- --framework=svelte
To get a trusted SSL certificate when testing locally, we use the mkcert
package,
see https://github.com/FiloSottile/mkcert
If you haven't used it before, you will need install it the first time.
$ mkcert -install
Created a new local CA
The local CA is now installed in the system trust store!
The local CA is now installed in the Firefox trust store (requires browser restart)!
Then your app can use a local cert with a shorter lifespan. These are stored in the
.cert
directory, and can be setup or refreshed with:
npm run cert
When running locally you can enable the inspector by pressing Cmd ⌘ + Shift ⇧ on Mac, otherwise Ctrl ⌃ + Shift ⇧. Then highlight and click on components.
See https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/inspector.md
To apply the recorded migrations, use:
$ npm run migration:add
or
$ npx wrangler d1 migrations apply DB --local
Migrations to be applied:
┌──────────────────┐
│ name │
├──────────────────┤
│ 0000_initial.sql │
└──────────────────┘
? About to apply 1 migration(s)
Your database may not be available to serve requests during the migration, continue? › (Y/n)
o Mapping SQL input into an array of statements
o Loading f6c5717c-3866-45d3-b4e7-20b332e359e0 from .wrangler/state/v3/d1
┌──────────────────┬────────┐
│ name │ status │
├──────────────────┼────────┤
│ 0000_initial.sql │ (tick) │
└──────────────────┴────────┘