Giter Club home page Giter Club logo

cf-svelte's Introduction

Sveltekit starter for Cloudflare that allows easier local development

This starter was initially created with C3 (Create Cloudflare CLI), and then enhanced with a few things:

  • Allow npm start to start a local dev environment (same as npm run dev)
  • Support for a trusted SSL cert using mkcert
  • Add the Svelte Inspector
  • Add an example migration for the database

create-svelte

The initial project was created with:

npm create cloudflare@latest cf-svelte -- --framework=svelte

mkcert

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

Svelte inspector

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

D1 Migration

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) │
└──────────────────┴────────┘

cf-svelte's People

Contributors

sdarnell avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.