Skip to content

Commit 7881f6d

Browse files
authored
Manifest test maybe (#555)
1 parent c9eb9f7 commit 7881f6d

File tree

10 files changed

+703
-2178
lines changed

10 files changed

+703
-2178
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The app will be available at <http://localhost:3000/>.
2929

3030
| Chrome | Firefox | Edge | Safari | Opera | Tor | Mobile |
3131
| ------ | ------- | ---- | ------ | ----- | --- | ------ |
32-
||||||||
32+
| | | | | | | |
3333

3434
## Known Issues
3535

docs/architecture/index.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This document provides a high-level overview of the architecture for AlexJSully'
1010
- **Testing:** Cypress (E2E), Jest (unit)
1111
- **Error Tracking:** Sentry
1212
- **Backend/Data:** Firebase
13-
- **PWA Support:** next-pwa
13+
- **PWA Support:** Native Next.js
1414

1515
## 📂 Directory Structure
1616

@@ -40,7 +40,8 @@ flowchart TD
4040
React_Components -->|UI| MUI
4141
NextJS_App -->|API| Firebase
4242
NextJS_App -->|Error| Sentry
43-
NextJS_App -->|Service Worker| PWA
43+
NextJS_App -->|Metadata| PWA_Manifest
44+
PWA_Manifest -->|Install| User_Device
4445
```
4546

4647
## 🧩 Subsystems

docs/architecture/pwa.md

Lines changed: 77 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,98 @@
11
# Service Workers & PWA Documentation
22

3-
This document explains how Progressive Web App (PWA) features and service workers are implemented in the AlexJSully Portfolio project.
3+
This document explains how Progressive Web App (PWA) features are implemented in the AlexJSully Portfolio project using native Next.js capabilities.
44

5-
## 📦 Purpose
5+
## Purpose
66

7-
PWA support enables offline access, faster load times, and installable experiences for users.
7+
PWA support enables:
88

9-
## 🏗️ Structure
9+
- **Installability**: Users can install the website as a standalone app.
10+
- **Offline Capabilities**: Basic offline support via browser caching and service workers (if configured).
11+
- **Native-like Experience**: Standalone display mode and custom icons.
1012

11-
## 🔍 Usage Example
13+
## Architecture
1214

13-
## 🚀 Features
15+
The PWA implementation relies on Next.js's built-in metadata and route handlers, specifically `manifest.ts`.
1416

15-
- **Offline caching:** Assets, pages, and API responses are cached for offline use.
16-
- **Service worker:** Handles background sync, cache updates, and push notifications.
17-
- **Web App Manifest:** Enables installability and controls app appearance on devices.
18-
- **Responsive design:** Optimized for mobile and desktop.
17+
```mermaid
18+
flowchart TD
19+
Browser[User Browser]
20+
Manifest["src/app/manifest.ts"]
21+
Icons["public/icon/"]
22+
NextJS[Next.js Server]
1923
20-
## ⚙️ Technical Implementation
24+
Browser -- Requests Manifest --> NextJS
25+
NextJS -- Generates JSON --> Manifest
26+
Manifest -- References --> Icons
27+
Browser -- Downloads --> Icons
28+
Browser -- Install Prompt --> User
29+
```
2130

22-
### next-pwa Configuration
31+
## Features
32+
33+
- **Dynamic Manifest**: Generated programmatically via `src/app/manifest.ts`.
34+
- **Responsive Icons**: Multiple icon sizes and maskable icons for different devices.
35+
- **Theming**: Custom theme and background colors defined in the manifest.
36+
- **Display Modes**: Supports `standalone`, `minimal-ui`, and `window-controls-overlay`.
37+
38+
## Technical Implementation
39+
40+
### Manifest Generation (`src/app/manifest.ts`)
41+
42+
Instead of a static `manifest.json`, we use a TypeScript file to generate the manifest dynamically. This allows for type safety and easier maintenance.
43+
44+
```typescript
45+
// src/app/manifest.ts
46+
import type { MetadataRoute } from 'next';
47+
48+
export default function manifest(): MetadataRoute.Manifest {
49+
return {
50+
name: "Alexander Sullivan's Portfolio",
51+
short_name: "Alexander Sullivan's Portfolio",
52+
// ... other properties
53+
icons: [
54+
{
55+
src: '/icon/android-chrome-192x192.png',
56+
sizes: '192x192',
57+
type: 'image/png',
58+
},
59+
// ... other icons
60+
],
61+
};
62+
}
63+
```
2364

24-
- The `next-pwa` plugin is configured in `next.config.js`:
25-
- Specifies service worker location, caching strategies, and runtime behaviors.
26-
- Example config:
65+
### Service Worker Lifecycle
2766

28-
```js
29-
// next.config.js
30-
const withPWA = require('next-pwa');
31-
module.exports = withPWA({
32-
pwa: {
33-
dest: 'public',
34-
register: true,
35-
skipWaiting: true,
36-
disable: process.env.NODE_ENV === 'development',
37-
},
38-
});
39-
```
67+
While `next-pwa` previously handled service worker generation, native Next.js apps can use manual service worker registration or rely on standard browser caching headers.
4068

41-
### Manifest & Icons
69+
```mermaid
70+
sequenceDiagram
71+
participant User
72+
participant Browser
73+
participant Network
74+
participant Cache
4275
43-
- `public/manifest.json` defines app name, icons, theme color, and display mode.
44-
- Icons for various devices are in `public/icon/`.
76+
User->>Browser: Visits Site
77+
Browser->>Network: Request Resources
78+
Network-->>Browser: Return Resources
79+
Browser->>Cache: Cache Static Assets (via Headers)
4580
46-
### Integration Flow
81+
opt Offline Mode
82+
User->>Browser: Visits Site (Offline)
83+
Browser->>Cache: Check Cache
84+
Cache-->>Browser: Return Cached Assets
85+
end
86+
```
4787

48-
1. User visits site; service worker is registered.
49-
2. Assets and pages are cached according to config.
50-
3. Manifest enables "Add to Home Screen" prompt.
51-
4. Updates are pushed via service worker when available.
88+
## Customization
5289

53-
## 🛠️ Customization & Extensibility
90+
To modify PWA settings:
5491

55-
- Modify caching strategies in `next.config.js` for custom needs.
56-
- Add push notification support via service worker.
57-
- Update manifest for branding and install experience.
92+
1. **Manifest**: Edit `src/app/manifest.ts` to change app name, colors, or icons.
93+
2. **Icons**: Add or replace images in `public/icon/` and update the manifest accordingly.
5894

59-
## 🔗 Related Docs
95+
## Related Docs
6096

6197
- [Architecture Overview](./index.md)
62-
- [Usage Guides](../usage/index.md)
98+
- [Next.js Manifest Documentation](https://nextjs.org/docs/app/api-reference/file-conventions/metadata/manifest)

next.config.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,7 @@ const { withSentryConfig } = require('@sentry/nextjs');
33

44
const isDevelopment = process.env.NEXT_PUBLIC_ENVIRONMENT === 'development';
55

6-
const withPWA = require('next-pwa')({
7-
buildExcludes: ['app-build-manifest.json'],
8-
dest: 'public',
9-
disable: isDevelopment,
10-
register: true,
11-
skipWaiting: true,
12-
});
13-
14-
const nextConfig = withPWA({
6+
const nextConfig = {
157
images: {
168
remotePatterns: [
179
{
@@ -63,7 +55,7 @@ const nextConfig = withPWA({
6355
},
6456
},
6557
},
66-
});
58+
};
6759

6860
const sentryWebpackPluginOptions = {
6961
// Suppresses source map uploading logs during build

0 commit comments

Comments
 (0)