Skip to content
/ pwa-kit Public template

๐Ÿ”ญ A Production-Ready Frontend Development Kit with Next.js + TypeScript.

License

Notifications You must be signed in to change notification settings

inodaf/pwa-kit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

an icon with tones of purple background and 4 lines representing a fast motion.
PWA Kit ยท Enterprise Apps

Starting a new Web App needs to be easy. PWA Kit provides a fully featured environment with Next.js + TypeScript and let you focus on code delivery without compromising best practices.

The Stack

Base

  • โšก๏ธ Next.js with TypeScript + Paths
  • ๐Ÿ“ฑ First Class PWA Support
  • ๐Ÿƒ Application Properties for Production, Staging and Development
  • ๐Ÿ‘ฉโ€๐ŸŽค CSS Styling with TailwindCSS or CSS Modules
  • โš›๏ธ Support for React Query
  • ๐Ÿ”’ Automatic local HTTPS with Caddy

Quality

  • ๐Ÿง‘โ€๐Ÿ”ฌ Testing with Jest + swc + @testing-library + Coverage Reports
  • ๐Ÿž Linting with TypeScript ESLint
  • ๐Ÿ“ Code Format with Prettier
  • ๐Ÿฅธ GraphQL and REST API mocking with MSW
  • ๐ŸŒฒ E2E Tests with Playwright

Security

  • ๐Ÿ‘ฎโ€โ™‚๏ธ Support for Content-Security-Policy
  • ๐Ÿ” CI Sec Inspection with Mozilla Observatory soon

Accessibility

Performance

  • ๐Ÿ“Š Core Web Vitals Report
  • ๐Ÿšฅ Lighthouse CI + Bundlesize soon

CI + Deployment

  • ๐Ÿ“ GitHub Actions for Test, Lint and Format
  • ๐Ÿš€ Deployment + Branch Preview soon

Getting Started

Base commands for develop, test and build.

Requirements

  • Node.js Toolchain Manager: Volta
  • Package Manager: pnpm
  • HTTP(S) Web Server: Caddy *optional

Prepare Development

A Makefile is used to orchestrate the installation of required tooling and dependencies. Open your Terminal app and run the command bellow, then you are able to get started. Make sure to install Caddy to enable HTTPS on Dev.

make

Note

In case of failure, head to the Troubleshooting section below for alternatives.

Development Server

The next command will spawn the Dev Server and load the environment variables from .env.

pnpm dev        # spawns the Dev Server at http://localhost:3000
pnpm dev:secure # spawns Caddy and the Dev Server at https://localhost:3000

Testing

There are Integration, Unit and E2E tests available and the matching test environment variables (.env.test) are automatically loaded. With the exception of E2E tests, these commands are also used for CI environments.

# Unit & Integration Tests
pnpm test     # run tests without watch
pnpm test:w   # run tests with watch
pnpm test:c   # run tests with coverage
pnpm t        # alias for `pnpm test`
# E2E Tests
pnpm test:e2e # runs with **dev server** as Base URL

Linting & Code Formatting

We split the process into Check and Fix commands.

# Linting
pnpm lint:check # checks linting without fixing (useful for CI)
pnpm lint       # checks linting and fixes issues
# Code Formatting
pnpm fmt:check # checks formatting without fixing (useful for CI)
pnpm fmt       # checks formatting and fixes issues

Environment Variables

Sensitive and secret data can be defined using Environment Variables. An .env file at the root directory can be used for storing these data. As per security .env files cannot be tracked through version control systems.

Application Properties

Application properties let you define environment-specific, static configuration for your system. Unlike Environment Variables, Properties cannot include sensitive values.

There are the base, dev, production and staging properties but it's possible to add many others, as they are named based on the value of APP_ENV and NEXT_PUBLIC_APP_ENV environment variable. Also they are separated by client and server.

The properties from base holds all the default configuration that applies for all environments. Overriding these values is made possible by using the environment specific property file, like dev.

In short, when APP_ENV and NEXT_PUBLIC_APP_ENV is set to production, base and production property files will be loaded and merged. Then they can be accessed through the application as bellow:

import { serverProperties } from "@/config/properties/server";
import { clientProperties } from "@/config/properties/client";

Building

Builds are separated by environments: Production and Staging. For both environments the NODE_ENV is set to production.

Production

pnpm build:prod # build with production bindings
pnpm start:prod # start the built app with production bindings

Staging

pnpm build:stag # build with staging bindings
pnpm start:stag # start the built app with staging bindings

Cleanup

Whenever you need a fresh start in case something is going wrong, you can leverage handy cleanup commands.

pnpm cleanup      # remove caches and temp files
pnpm cleanup:hard # same as above but also remove `node_modules`

Troubleshooting

Fail while using the make command: Behind the scenes this command depends on cURL for downloading Volta and pnpm binaries. Try installing cURL then run the command again. Also, the commands from Makefile are not supported on Windows machines so the alternative is to manually installing the required dependencies.


License

Although this template is MIT licensed, if needed, you must change the license after creating your project.