- π About the Project
- π· Gallery
- π Features
- πΌ Lighthouse Performance
- π Built With
- πββοΈ Getting Started
- π« Quick Start
- π Directory Structure
- π¨βπ» Starting Development
- π’ Deploy your own
- π€ Contributing
- π Show your support
- β Donate
- π οΈ Author
- π License
Next.js PWA template πΎ is a starter template that provides a comprehensive setup for building a progressive web app (PWA) using the Next.js framework. Don't worry about the configuration π¨ this template will take care of that, focus on your codesβ¨οΈ and project ideasπ‘
This template includes a pre-configured setup for service workers, offline support, and manifest files, making it easy for developers to create a high-performing PWA with minimal setup. The template also includes a basic layout and routing system, along with some basic components and styles, to help developers get started quickly. This template give you the end to end type safety. Additionally, it includes a range of popular libraries and tools, such as Prettier, ESLint, and Tailwind CSS, to ensure that the code is well-formatted and follows best practices. With the help of this template, developers can easily create a fast and reliable PWA that can work seamlessly across all devices.
π Dark mode
π¦ Light mode
π Dark mode
π¦ Light mode
- πΎ Cats Realm PWA using Next 13
- π Awesome dark/light themes
- π± Native like mobile experience
- π― Make Development simple
- π Vscode debugging
- π₯ Hot Module Replacement(HMR)
- πͺ Eslint, Prettier and Airbnb make your code stronger
- π₯ Build your application for multi-platform
The Next.js PWA Template achieve a 100% score in Google Lighthouse
Next.js PWA Template Built With
These instructions will get you a copy of the Next.js PWA Template and running on your local machine for development and testing purposes. See Deploy for notes on how to lunch your PWA app in live.
Before you begin i recommend you read about the basic building blocks that assemble a Next.js PWA Template:
-
React.js - React's Official Website is a great starting point. You can also use W3Schools Popular Guide, and Egghead Videos.
-
Next.js - The best way to understand Next.js is through its Official Website, which has a Getting Started guide, You can also go through this TutorialsPoint Guide for more resources.
-
TypeScript - Go through TypeScript Official Website and proceed to their Official Manual, which should help you understand TypeScript better.
-
Node.js - Start by going through Node.js Official Website and this StackOverflow Thread, which should get you going with the Node.js platform in no time.
Make sure you have installed all of the following prerequisites on your development machine:
- Git - Download & Install Git. OSX and Linux machines typically have this already installed.
- Node.js - Download & Install Node.js and the npm package manager. If you encounter any problems, you can also use this GitHub Gist to install Node.js.
NOTE: This project requires NodeJS (version 14 or later) and NPM. Node and NPM are really easy to install.
There are several ways you can get the Next.js PWA Template:
The recommended way to get Next.js PWA Template is to use git to directly clone the repository:
# Clone the project
git clone https://github.com/AjayKanniyappan/nextjs-pwa-template.git <your-project-name>
# Enter the project directory
cd <your-project-name>
This will clone the latest version of the Next.js PWA Template repository to a nextjs-pwa-template folder.
Another way to use the Next.js PWA Template is to download a zip copy from the main branch on GitHub. You can also do this using the wget
command:
wget https://github.com/AjayKanniyappan/nextjs-pwa-template/archive/refs/heads/main.zip -O nextjs-pwa-template-main.zip; unzip nextjs-pwa-template-main.zip; rm nextjs-pwa-template-main.zip
Don't forget to rename nextjs-pwa-template-main after your project name.
Once you've downloaded the Template and installed all the prerequisites, you're just a few steps away from starting to develop your Progressive Web App using Next.js.
The Template comes pre-bundled with a package.json
file that contain the list of modules you need to start your application.
To install the dependencies, run this in the application folder from the command-line:
# Install dependency
npm install
Or if you prefer using Yarn:
# Install dependency
yarn install
This command does a few things:
- First it will install the dependencies needed for the application to run.
- If you're running in a development environment, it will then also install development dependencies needed for testing and running your application.
Next.js PWA Template files and folder structure.
+βββ .husky Automate your git commits
βββ .next Contains the minimized version of the source code
+βββ .vscode vscode debug folder and extension support
β
+βββ public Project assets folder
β βββ icons Icon sets folder
β β βββ NxN.png Different pixel png's
β βββ manifest.json Manifest for PWA application
β
+βββ src Source code folder
β βββ common It contains common data
β βββ components This folder consists of a collection of UI components
β βββ constants It contains constant urls and data
β βββ hooks It contains custom hooks for all pages
β βββ layouts It contains page layout
β βββ pages Pages and indicate the routes
+β β βββ index.tsx Starting point of the application
β βββ services It contains API Services
β βββ styles It contains css styles
β βββ svg It contains SVG Vectors
β βββ types Typescript types declaration folder
β βββ utils It contains a set of utility functions
β
βββ .editorconfig EditorConfig for defining coding styles
βββ .eslintrc.json Eslint configurations
βββ .prettierrc prettier code formatter
+βββ next.config.js Next.js PWA configurations
+βββ package.json Package.json for development
|ββ postcss.config.js Post CSS configurations
+βββ tailwind.config.js Tailwind CSS configurations
βββ tsconfig.json TypeScript Configuration
+βββ tsconfig.node.json TypeScript paths
Use your favorite JavaScript Package Managers npm or yarn or pnpm
Run your application using npm:
npm run dev
Or if you prefer using Yarn:
yarn dev
Your Next.js application should run on port 5050 with the development environment configuration, so in your browser just go to http://localhost:5050
That's it! Your application should be running. To proceed with your development, check the other sections in this documentation. If you encounter any problems, Feel free to check issues page.
If the localhost 5050 port number already in use! or if you like to change your Next.js application number.
Go to π package.json and change the port number 5050 to your-port-number
This guide goes over how to start VSCode debugging your Next.js, react Project.
you can easily debug this nextjs-pwa-template.
To bring up the Run and Debug view, select the Run and Debug icon in the Activity Bar on the side of VS Code. You can also use the keyboard shortcut Ctrl+Shift+D
.
Click the button or press F5
to start debugging
If you want clean the cache files and node_modules cache run this below command π:
npm run clean
NOTE: It will remove your node_module folder, build files and env files.
The Next.js PWA Template has Eslint, Prettier and Airbnb Configurations, this will help you to Style your code and syntax check and more.
Eslint will check syntax, find problems, and enforce code style of your code.
Prettier will format your code style.
All you have to do is run this below command π:
npm run lint
NOTE: This command show you the warnings and errors in your code.
Automate your Git commits using Husky, and don't commit or push the bad code in git.
Husky improves your commits and more, You can use it to lint your commit messages, run tests, lint code, etc... when you commit or push. Husky supports all Git hooks.
Run below command π to prepare Husky:
npm run prepare
See docs and more about Husky.
That's it! Your application should be running. To proceed with your development, check the other sections in this documentation. If you encounter any problems, Feel free to check issues page.
Congratulations, you are ready to deploy your Next.js PWA Template to production. This document will teach how to deploy vercel or self-hosted.
The easiest way to deploy Next.js to production is to use the Vercel platform developed by the creators of Next.js.
NOTE: If you want to read more about vercel, kindly read this π Documentation.
Next.js PWA Template can be deployed to any hosting provider that supports Node.js.
If youβve followed the instructions so far, your package.json should have the following build and start scripts:
"scripts": {
"build": "next build",
"clean": "git clean -dfX",
"dev": "next dev -p 5050",
"lint": "next lint --fix --max-warnings 0 .",
"prepare": "husky install",
"start": "next start -p 5050"
}
npm run build
In your own hosting provider, run the build script once, which builds the production application in the .next
folder.
After building, the start script starts a Node.js server that supports hybrid pages, serving both statically generated and server-side rendered pages, and API Routes.
npm run start
NOTE: If you want to read more about deployment, kindly read this π Documentation.
Contributions, issues and feature requests are welcome! Just be sure to read the contributing document to get started. Feel free to check issues page.
I hope π it will helped you! Give a βοΈ to support this project!
If you like π the project, there is other way to support us
- Tweet about it
- Refer this project in your project's readme
- Mention the project at local meetups and tell your friends/colleagues
Donations will help us to ensure the following:
- β‘ Quick responses to issues, bug reports and help requests
- β Adding new features
- βοΈ Long term maintenance of the project
π¨βπ» Ajay Kanniyappan
- Website: https://ajaykanniyappan.com
- Twitter: @AjayKanniyappan
- Github: AjayKanniyappan
- LinkedIn: Ajay Kanniyappan
MIT License Β© Ajay Kanniyappan