An open API service indexing awesome lists of open source software.

https://github.com/azimonti/progressive-web-app-template-2

A Progressive Web Application (PWA) template featuring local file management and optional Dropbox / Google Drive integration.
https://github.com/azimonti/progressive-web-app-template-2

dropbox-sdk progressive-web-app pwa react vite

Last synced: 2 months ago
JSON representation

A Progressive Web Application (PWA) template featuring local file management and optional Dropbox / Google Drive integration.

Awesome Lists containing this project

README

          

# Progressive Web App Template

A modern **Progressive Web App (PWA)** template built with **Vite**, **React**, **TypeScript**, and **Tailwind CSS v4**.
Designed for fast startup, clean structure, and zero config overhead β€” ideal for creating installable, offline-capable web apps.

---

## πŸš€ Stack

| Tool | Purpose |
|------|----------|
| [Vite](https://vite.dev) | Lightning-fast development and build tooling |
| [React](https://react.dev) | UI library |
| [TypeScript](https://www.typescriptlang.org/) | Static typing |
| [Tailwind CSS v4](https://tailwindcss.com/) | Utility-first CSS framework (no config required) |
| [pnpm](https://pnpm.io/) | Fast, disk-efficient package manager |

---

## 🧩 Features

- ⚑ Instant startup with Vite
- 🎨 Tailwind CSS v4 (config-free setup)
- πŸ“± PWA-ready: add manifest and service worker easily
- 🧱 TypeScript-first React components
- πŸ”₯ Hot Module Replacement (HMR) out of the box
- 🧼 Clean, flat project structure (no unnecessary scaffolding)
- ✨ **Font Awesome** icons ready to use across the UI (brands + solid packs)
- ☁️ **Full cloud storage integration** with Dropbox and Google Drive
- πŸ” Secure OAuth authentication (PKCE for Dropbox, Google Identity Services for Drive)
- πŸ”„ Automatic file synchronization between local and cloud storage
- βš–οΈ Intelligent conflict resolution for local vs. remote files
- πŸ“Š Storage quota management (5MB per file, 50MB total)
- πŸ” Token refresh and persistent authentication
- 🌐 Cross-platform file access and backup

---

## πŸ› οΈ Setup

```bash
# Install dependencies
pnpm install

# Start development server
pnpm dev

# Build for production
pnpm build

# Preview production build
pnpm preview
````

Open [http://localhost:5173](http://localhost:5173) in your browser.

### UI Icons with Font Awesome

- Font Awesome core is configured in `src/main.tsx` (`config.autoAddCss = false`) and styles are imported once via `@fortawesome/fontawesome-svg-core/styles.css`.
- Import icons directly where they are used, e.g.

```tsx
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faDropbox } from '@fortawesome/free-brands-svg-icons';


```

- The template already uses brand icons for the cloud provider dropdown and solid icons for toast notifications and chevrons. Add additional icons on a per-component basisβ€”no central icon registry is necessary.

### Optional: Cloud Sync

The template can mirror saved files to a cloud provider. Once configured, use the dropdown in the UI to choose Dropbox or Google Drive and connect.

#### Dropbox

1. Create a scoped Dropbox app in the [Dropbox App Console](https://www.dropbox.com/developers/apps) requesting these permissions: `files.metadata.read`, `files.metadata.write`, `files.content.read`, `files.content.write`.
2. Add your development URL (e.g. `http://localhost:5173/`) to the app's redirect URIs.
3. Open `src/services/CloudConfig.ts` and set `DROPBOX_APP_KEY` to your Dropbox app key.
4. Start the app (`pnpm dev`) and click **Connect Dropbox** to complete the OAuth flow. The redirect URI automatically matches the current origin (e.g. `http://localhost:5173/` or your production URL), so make sure each is added to your Dropbox app configuration.

#### Google Drive

1. Create or reuse a Google Cloud project and [enable the Drive API](https://console.cloud.google.com/apis/library/drive.googleapis.com).
2. Configure an OAuth 2.0 **Web application** client ID in the Google Cloud Console. Add your dev and production URLs (e.g. `http://localhost:5173/`) to **Authorized JavaScript origins** and **Authorized redirect URIs**.
3. Open `src/services/CloudConfig.ts` and set `GOOGLE_DRIVE_CLIENT_ID` to your Google OAuth client ID.
4. (Optional) Adjust `GOOGLE_DRIVE_FOLDER_NAME` in the same file if you want a different target folder.
5. Start the app (`pnpm dev`) and click **Connect Google Drive**. Sign in with an account that has access to the Drive API for the project.

Synced files are created inside a Drive folder named after `GOOGLE_DRIVE_FOLDER_NAME` (defaults to `pwa-template`) at the root of the user's Drive, so they can be managed manually if needed.

---

## πŸ“¦ Directory Structure

```
.
β”œβ”€β”€ index.html
β”œβ”€β”€ postcss.config.js
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ tsconfig.app.json
β”œβ”€β”€ tsconfig.node.json
β”œβ”€β”€ vite.config.ts
β”œβ”€β”€ eslint.config.js
β”œβ”€β”€ firebase.json
β”œβ”€β”€ .firebaserc
β”œβ”€β”€ public/
β”‚ β”œβ”€β”€ manifest.webmanifest
β”‚ β”œβ”€β”€ sw.js
β”‚ └── img/
β”‚ β”œβ”€β”€ social-card.jpg
β”‚ └── icons/
β”‚ β”œβ”€β”€ pwa-template-32x32.png
β”‚ β”œβ”€β”€ pwa-template-180x180.png
β”‚ β”œβ”€β”€ pwa-template-192x192.png
β”‚ β”œβ”€β”€ pwa-template-512x512-maskable.png
β”‚ β”œβ”€β”€ pwa-template-512x512.png
β”‚ └── pwa-template.ico
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ App.tsx
β”‚ β”œβ”€β”€ main.tsx
β”‚ β”œβ”€β”€ index.css
β”‚ β”œβ”€β”€ i18n.ts
β”‚ β”œβ”€β”€ components/
β”‚ β”‚ β”œβ”€β”€ ConfirmationDialog.tsx
β”‚ β”‚ β”œβ”€β”€ LanguageSwitcher.tsx
β”‚ β”‚ └── Toast.tsx
β”‚ β”œβ”€β”€ locales/
β”‚ β”‚ β”œβ”€β”€ en.json
β”‚ β”‚ └── ja.json
β”‚ └── services/
β”‚ β”œβ”€β”€ CloudConfig.ts
β”‚ β”œβ”€β”€ CloudStorage.ts
β”‚ β”œβ”€β”€ DropboxAuthService.ts
β”‚ β”œβ”€β”€ DropboxStorageService.ts
β”‚ β”œβ”€β”€ FileStorageService.ts
β”‚ β”œβ”€β”€ GoogleDriveAuthService.ts
β”‚ └── GoogleDriveStorageService.ts
└── package.json
```

---

## 🧰 PWA Notes

To make this a full PWA:

1. Add a `manifest.webmanifest` in the project root.
2. Register a service worker (e.g., using [Workbox](https://developer.chrome.com/docs/workbox)).
3. Configure Vite’s [PWA plugin](https://vite-pwa-org.netlify.app/).

Example minimal service worker:

```ts
self.addEventListener('install', () => self.skipWaiting());
self.addEventListener('fetch', () => {});
```

---

## πŸ§‘β€πŸ’» Author

**Marco Azimonti**
[https://github.com/azimonti](https://github.com/azimonti)

---

## πŸͺͺ License

This project is licensed under the [MIT License](./LICENSE).