forked from shadowwalker/next-pwa
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
337 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<CodeShowcase> | ||
|
||
```js | ||
// title next.config.js | ||
const withPWA = require("@ducanh2912/next-pwa").default({ | ||
dest: "public", | ||
}); | ||
|
||
module.exports = withPWA({ | ||
// Your Next.js config | ||
}); | ||
``` | ||
|
||
## Easy to setup | ||
|
||
Just wrap your Next config with `withPWA` and you are ready to go! You do not need to configure much, but there are many options to customize `next-pwa` to your | ||
liking. | ||
|
||
</CodeShowcase> | ||
|
||
<CodeShowcase invert> | ||
|
||
```js | ||
// title next.config.js | ||
// @ts-check | ||
const withPWA = require("@ducanh2912/next-pwa").default({ | ||
// You will get hints as you type here. You can also hover over these options | ||
// to get a detailed description about them! | ||
dest: "public", | ||
}); | ||
|
||
// Your Next config is automatically typed with NextConfig! | ||
module.exports = withPWA({ | ||
reactStrictMode: "true", // Type 'string' is not assignable to type 'boolean | null | undefined'. | ||
}); | ||
``` | ||
|
||
## Typescript support | ||
|
||
`next-pwa` is built with Typescript. As you configure `next-pwa`, you will get type hints and detailed description of its options. If you directly wrap your | ||
Next config with `withPWA`, it will automatically be typed with `NextConfig`! | ||
|
||
</CodeShowcase> | ||
|
||
<CodeShowcase> | ||
|
||
```js | ||
// title next.config.js | ||
const withPWA = require("@ducanh2912/next-pwa").default({ | ||
dest: "public", | ||
// disable: process.env.NODE_ENV === "development", | ||
// register: true, | ||
// scope: "/app", | ||
// sw: "service-worker.js", | ||
// customWorkerDir: "service-worker", | ||
// cacheStartURL: true, | ||
// dynamicStartUrl: true, | ||
// dynamicStartUrlRedirect: "/foo/bar", | ||
// cacheOnFrontendNav: true, | ||
// aggressiveFrontEndNavCaching: true, | ||
// scope: "/beta", | ||
// swcMinify: true, | ||
// workboxOptions: {}, | ||
// ... | ||
}); | ||
|
||
module.exports = withPWA({ | ||
// Your Next.js config | ||
}); | ||
``` | ||
|
||
## Configurable | ||
|
||
There are just [so many options](/docs/next-pwa/configuring) thanks to Workbox's extensive API 🤯 You can disable the plugin, change how it caches stuff | ||
at runtime, silent its logging, add your custom code to the service worker or even write the service worker yourself! | ||
|
||
We are working hard to add useful features to the plugin! You can help by [contributing to the repository](https://github.com/DuCanhGH/next-pwa/tree/master/contributing) | ||
or [creating feature requests](https://github.com/DuCanhGH/next-pwa/issues/new/choose)! | ||
|
||
</CodeShowcase> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { ReactNode } from "react"; | ||
|
||
import { clsx } from "@/utils/clsx.js"; | ||
|
||
export const CodeShowcase = ({ | ||
children, | ||
invert, | ||
}: { | ||
children: ReactNode[]; | ||
invert: boolean; | ||
}) => { | ||
const [code, ...others] = children; | ||
return ( | ||
<div className="flex w-full flex-col gap-4 py-4 md:flex-row md:gap-24 md:py-10"> | ||
<div | ||
className={clsx( | ||
invert && "md:order-last", | ||
"overflow-hidden md:flex-[3_3_0] [&>span]:mt-0" | ||
)} | ||
> | ||
{others} | ||
</div> | ||
<div className="overflow-hidden md:flex-[2_2_0]">{code}</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
interface Feature { | ||
icon: string; | ||
label: string; | ||
description: string; | ||
} | ||
|
||
export const FEATURES_LIST: Feature[] = [ | ||
{ | ||
icon: "✊", | ||
label: "Zero-config", | ||
description: "No configuration needed to get started...", | ||
}, | ||
{ | ||
icon: "⛏️", | ||
label: "Configurable", | ||
description: | ||
"...yet there are many options available to extend the plugin.", | ||
}, | ||
{ | ||
icon: "💯", | ||
label: "Fast", | ||
description: "Blow your user's mind with a website as fast as lightning ⚡", | ||
}, | ||
{ | ||
icon: "🔌", | ||
label: "Offline", | ||
description: "Proper offline support. For both App and Pages Router.", | ||
}, | ||
{ | ||
icon: "🚀", | ||
label: "Developer experience", | ||
description: | ||
"Built-in Typescript definitions and JSDoc to enable the best DX.", | ||
}, | ||
]; |
Oops, something went wrong.