πΎ
Cats Realm A Solid Foundation for Building Scalable and Efficient Progressive Web Application!
π Live Demo
β© Table of contents
π 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
π About the Project
Next.js PWA template
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.
π· Gallery
π₯οΈ Desktop
π± Mobile
π Features
πΎ 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
πΌ Lighthouse Performance
The Next.js PWA Template achieve a 100% score in Google Lighthouse
π Built With
Next.js PWA Template Built With
πββοΈ Getting Started
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
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.
π₯οΈ Prerequisites
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.
π« Quick Start
There are several ways you can get the Next.js PWA Template:
π Cloning The GitHub Repository
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.
ποΈ Downloading The Repository Zip File
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.
π§° Quick Install
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.
π Directory Structure
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
π¨βπ» Starting Development
Use your favorite JavaScript Package Managers npm or yarn or pnpm
π Running Your Application
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.
π¬ Change Port Number
If the localhost 5050 port number already in use! or if you like to change your Next.js application number.
Go to
π Vscode Debugging
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
π§Ή Clean Cache
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.
π Style your Code
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.
π°οΈ Git Commits
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
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.
π’ Deploy your own
Congratulations, you are ready to deploy your Next.js PWA Template to production. This document will teach how to deploy vercel or self-hosted.
πΌ Vercel
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
π» Self-Hosting
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
π€ Contributing
Contributions, issues and feature requests are welcome! Just be sure to read the contributing document to get started. Feel free to check issues page.
π Show your support
I hope
If you like
- Tweet about it
- Refer this project in your project's readme
- Mention the project at local meetups and tell your friends/colleagues
β Donate
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
π οΈ Author
- Website: https://ajaykanniyappan.com
- Twitter: @AjayKanniyappan
- Github: AjayKanniyappan
- LinkedIn: Ajay Kanniyappan
π License
MIT License Β© Ajay Kanniyappan