Coder Social home page Coder Social logo

fxmt2009 / sveltekitpwa Goto Github PK

View Code? Open in Web Editor NEW

This project forked from funmiles/sveltekitpwa

0.0 0.0 0.0 1.41 MB

An experimental Progressive Web App based on Svelte-kit

Home Page: sveltekit-pwa.vercel.app

JavaScript 2.87% CSS 5.66% HTML 0.85% TypeScript 18.44% Svelte 72.17%

sveltekitpwa's Introduction

Svelte-kit Progressive Web App skeleton.

Everything you need to build a Progressive Web App Svelte-kit project.

Creating a project

# Clone the project, free of git for your own project
degit [email protected]:FunMiles/SveltekitPWA.git MyApp
cd MyApp
# Install the dependencies
npm install
# or use pnpm install

Developing your code

Once you've created a project and installed dependencies with npm install (or pnpm install or yarn), start a development server:

npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open

Testing the service-worker locally

To test the service worker code and obtaining a lighthouse score, do the following operations:

# build the compiled code.
npm run build
# run the preview server.
npm run preview

Building

Before creating a production version of your app, install an adapter for your target environment. Then:

npm run build

You can still preview the built app with npm run preview, regardless of whether you installed an adapter. This should not be used to serve your app in production.

The degit code has the vercel adapter by default. If you plan to use vercel, you are set. Otherwise, replace the default with your prefered adapter.

Basic App

The git app is available as a vercel app for yours to try installing as a PWA: https://sveltekit-pwa.vercel.app/

Adjusting the list of routes

Because of the way svelte-kit serves the various routes, to be able to cold start or force-reload the PWA while offline, the service-worker needs to pre-cache all of the routes URLs. Whenever you add or remove routes, edit service-worker.js and modify the line specifying the routes to cache with your own list of routes:

// Edit the list of routes so they get cached and routed correctly, allowing
// cold start or hot reload to work offline.
const skRoutes = [ '/', '/about', '/todos' ];

Manifest, icons and description meta-data

Before publishing your own app, do not forget to modify the manifest file (static/manifest.webmanifest), overwriting the icon files (see https://github.com/onderceylan/pwa-asset-generator for an easy generator) and the meta description tag in src/routes/__layout.svelte

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.