A modern, full-stack Progressive Web Application built with Next.js 14, featuring Web3 authentication with thirdweb, and offline capabilities powered by Serwist.
- π Web3 Authentication: Seamless wallet connection and user authentication using thirdweb
- π± Progressive Web App: Full PWA capabilities with offline support via Serwist
- π Push Notifications: Web push notifications for user engagement
- π Dark/Light Mode: Responsive design with theme support
- π± Mobile-First: Optimized for mobile devices with install prompts
- β‘ Modern Stack: Built with Next.js 14, TypeScript, and Tailwind CSS
- Frontend: Next.js 14, React 18, TypeScript
- Styling: Tailwind CSS
- Web3: thirdweb, Wagmi, Viem
- PWA: Serwist (Service Worker)
- Notifications: Web Push API
Before you begin, ensure you have the following installed:
- Node.js (v18 or higher)
- npm or yarn
- A thirdweb account and Client ID from thirdweb.com
git clone <repository-url>
cd next14-thirdweb-serwist
npm install
Create a .env.local
file in the root directory:
# Option 1: Copy from example (if .env.example exists)
cp .env.example .env.local
# Option 2: Create manually
touch .env.local
Add the following environment variables to your .env.local
file:
# thirdweb Configuration (Required)
NEXT_PUBLIC_THIRDWEB_CLIENT_ID=your_thirdweb_client_id_here
# Web Push
WEB_PUSH_EMAIL=user@example.com
WEB_PUSH_PRIVATE_KEY=your_vapid_private_key
NEXT_PUBLIC_WEB_PUSH_PUBLIC_KEY=your_vapid_public_key
Important: Replace all placeholder values with your actual credentials. See the steps below for obtaining these values.
Generate VAPID keys for web push notifications:
npx web-push generate-vapid-keys --json
Copy the generated keys to your .env.local
file.
- Visit thirdweb.com and create an account
- Create a new project and copy your Client ID
- Add the Client ID to your
.env.local
file
To learn how to create a client ID, refer to the client documentation.
npm run dev
The application will be available at http://localhost:3000
.
For full PWA functionality (including install prompts):
npm run build && npm run start
- Desktop: Install button appears in supported browsers
- Mobile: Add to Home Screen prompts on iOS/Android
- Offline: Service worker enables offline functionality
The app includes web push notification capabilities for user engagement and updates.
Important
Enable notifications for the best experience!
To receive push notifications from this app, you need to enable notifications in your browser and/or system settings:
Chrome/Edge:
- Click the lock icon π in the address bar
- Set "Notifications" to "Allow"
- Or go to Settings β Privacy and security β Site Settings β Notifications
Firefox:
- Click the shield icon π‘οΈ in the address bar
- Turn off "Enhanced Tracking Protection" for this site (if needed)
- Allow notifications when prompted
- Or go to Settings β Privacy & Security β Permissions β Notifications
Safari:
- Go to Safari β Settings β Websites β Notifications
- Find your site and set it to "Allow"
macOS:
- System Preferences β Notifications & Focus
- Find your browser and ensure notifications are enabled
- Check "Allow notifications from websites" in browser settings
Windows:
- Settings β System β Notifications & actions
- Ensure your browser can send notifications
- Check browser notification settings
iOS:
- Settings β Notifications β [Your Browser]
- Enable "Allow Notifications"
- Also enable in browser settings
Android:
- Settings β Apps β [Your Browser] β Notifications
- Enable notifications
- Check browser notification permissions
Note
The SendNotification.tsx
component is sample code that requires backend implementation:
- Save subscription data when users subscribe (see TODO comments in code)
- Delete subscription data when users unsubscribe
- Implement
/notification
endpoint to send actual push notifications - Use
web-push
library or similar for server-side notification delivery
To customize your push notification content, edit app/notification/route.ts
and modify the title
, message
, icon
, and other properties in the sendNotification
call.
next14-thirdweb-serwist/
βββ app/
β βββ components/ # React components
β β βββ InstallPWA.tsx # PWA install prompt
β β βββ ...
β βββ ~offline/ # Offline page
β βββ ...
βββ public/ # Static assets
βββ ...
- thirdweb Client: thirdweb authentication integration
- InstallPWA: PWA installation prompts
The app integrates with:
- thirdweb: For Web3 authentication and blockchain interactions
- Web Push API: For notifications
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Join Monad Dev Discord
- Review the thirdweb documentation
- Check the Next.js 14 documentation
- Check the Serwist documentation