Giter Site home page Giter Site logo

Comments (17)

addyosmani avatar addyosmani commented on April 27, 2024 46

<3 Nuxt. If y'all decide to explore PWAs, our team on Chrome also work on Service Worker libraries and tools (sw-precache, sw-toolbox, offline-analytics, background-sync) and would be happy to provide some pointers.

from nuxt.js.

pi0 avatar pi0 commented on April 27, 2024 23

Just prepared nuxt-starter-pwa template which brings PWA and manifest generation out of the box into Nuxt ๐Ÿ˜Ž ( nuxt.config.js )

image

from nuxt.js.

Atinux avatar Atinux commented on April 27, 2024 18

Thank you a lot @WinstonFassett for sharing your experience with Nuxt and offline-plugin.

We will take a look with my brother when the 1.0 of nuxt.js will be out and our focus will be on the PWA, thanks to you guys we have already some direction to make nuxt create PWA ๐Ÿ˜ƒ

from nuxt.js.

alexchopin avatar alexchopin commented on April 27, 2024 8

Hi @addyosmani,
It's actually in our plan to make Nuxt a Framework wich includes all your need to create PWA easily.
Would be nice to see more about your Service Worker libraries and tool ๐Ÿ‘

from nuxt.js.

Atinux avatar Atinux commented on April 27, 2024 7

I was also thinking about it, I will try to make the documentation a PWA, I'm actually using lighthouse to check the most "tasks" I can.

If some tasks can be achieved trough Nuxt.js, the feature will be added to it.

I keep this issue open to let people add their knowledge about PWA and in which way Nuxt.js can help to create easily progressive web applications to make the web faster ๐Ÿ”ฅ

Thank you @dan-gamble for you implication ๐Ÿ‘

from nuxt.js.

vladejs avatar vladejs commented on April 27, 2024 6

I think this feature would put nuxt to another whole level, since a lot of developers will use PWA to fill the gap of missing native apps for their products.

This article explains what a PWA is and shows a detailed example on building one:

https://www.smashingmagazine.com/2016/08/a-beginners-guide-to-progressive-web-apps/#top

from nuxt.js.

buhrmi avatar buhrmi commented on April 27, 2024 5

Somebody make a nuxt/pwa template? :)

from nuxt.js.

afifsohaili avatar afifsohaili commented on April 27, 2024 4

would love to see nuxt + pwa

from nuxt.js.

WinstonFassett avatar WinstonFassett commented on April 27, 2024 3

I did a little experiment where I got the offline-plugin (https://github.com/NekR/offline-plugin) working with Nuxt, but I had to make a couple of changes to Nuxt.

My biggest problem was that the OfflinePlugin was generating the service worker sw.js file in the "_nuxt" folder. While I was able to get it to cache my index route ('/'), it was unable to load it when offline. It seems that scoping problems prevented the browser from using the cache for anything outside the _nuxt folder (everything else).

I couldn't find a way around this, so I forked Nuxt and removed the usage of "_nuxt/". Everything seemed to work fine, but I would rather have found another way to dynamically generate the sw.js file at the root of the site.

The other problem was that the OfflinePlugin should not be included in the server build because it will overwrite the sw.js generated by the client build. I couldn't find a good way to enable it for just the client build, so I added a config option, build.clientPlugins, so that in my nuxt.config.js, I have:

  build: {
    clientPlugins: [
      new OfflinePlugin({
        caches: {
          main: [':rest:', ':externals:']
        },
        externals: ['/', '/offline', '/about', '/help']
      })
    ]
  }

This will generate a service worker that will precache all the webpack build outputs along with any paths specified in externals. With the above config, it caches a few server-rendered pages listed in externals. It can also cache stuff made available via static/.

With those items cached, the user can load any of those URLs in the browser while offline. The cached "/about" page still says "This page is loaded from the server", which is kinda cool, but doing that kicks off a load of server rendering as it starts pre-caching those pages. It probably makes more sense to only cache the shell/index route and provide an "entry" handler to OfflinePlugin which would just intercept every request and handle routes client-side.

i.e. while offline with the service worker installed, going to /about should be handled by the service worker 1) returning a cached root shell (i.e. "/") and then 2) dynamically loading the remainder of the route. In that case, loading /about while offline would always say "this page is loaded from the client" regardless of how you browse to it. This would be nice because the server would only need to do server rendering for first-time visitors who have never installed the service worker. All return visitors could get 100% client rendering. Theoretically. I haven't tried that bit and am not sure how much further I will go with it.

That was my experience with https://github.com/NekR/offline-plugin. Again, I had to hack on Nuxt itself in order to get it generate the sw.js in the right place and to exclude the plugin from the server build, but maybe there's another way.

from nuxt.js.

Atinux avatar Atinux commented on April 27, 2024 3

It's now possible with https://github.com/nuxt-community/pwa-template ๐Ÿ™Œ

from nuxt.js.

ryandeussing avatar ryandeussing commented on April 27, 2024 2

Here's a recent PWA talk that may be of interest:
https://www.youtube.com/watch?v=By-iWxp_3vA&list=UU_DH6Z_K_3JRgOdDnwHLrLw

Slides:
Part 1 (Background): https://drive.google.com/open?id=0ByaMoD6mi690TWJPVndpNF9hbG8
Part 2 (Tools): https://drive.google.com/open?id=0ByaMoD6mi690TVhiWmdDcEdWV28

from nuxt.js.

dan-gamble avatar dan-gamble commented on April 27, 2024

Awesome, looking forward to seeing what comes of this ๐Ÿ‘

from nuxt.js.

apertureless avatar apertureless commented on April 27, 2024

Sounds good!
I've got a basic service worker up and running. And it kind of works fine with nuxt. However it would need some work to cache the assets which get hashed by webpack.

from nuxt.js.

rwatts3 avatar rwatts3 commented on April 27, 2024

Nice work @pi0

from nuxt.js.

daviddsp avatar daviddsp commented on April 27, 2024

Hello everyone.

Is possible to used a web app aplications with SSR in nuxt?

My ideas is to generate service workers for to send push notifications to my users.

Any ideas?

from nuxt.js.

pi0 avatar pi0 commented on April 27, 2024

https://pwa.nuxtjs.org/modules/onesignal.html

from nuxt.js.

lock avatar lock commented on April 27, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from nuxt.js.

Related Issues (20)

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.