Guide to Node Js Manifest.json file | WebApp

The manifest.json file in a Node.js application is a JSON file that contains metadata about the application. This file is typically located in the root directory of the application and is used to define information such as the application's name, version, and entry point (the file that starts the application).

It can also include other information such as dependencies, scripts, and web application manifest properties. The file is used by other tools, such as package managers or build systems, to automatically configure and manage the application.

Manifest.json properties

The manifest.json file in a Node.js application can contain a variety of properties, some of which are commonly used include:

These are some common properties that can be used, but it is not limited to this, manifest.json can also include other properties depending on the use case.

Manifest.json file example in Nodejs

Here is an example of a manifest.json file for a basic Node.js application:

 "name": "my-node-app", 
 "version": "1.0.0", 
 "description": "A simple Node.js application", 
 "main": "index.js", 
 "scripts": { 
 "start": "node index.js", 
 "test": "jest" 
 "dependencies": { 
 "express": "^4.17.1" 
 "devDependencies": { 
 "jest": "^26.4.2" 
 "author": "John Doe", 
 "license": "MIT" 

In this example, the application is named "my-node-app", has a version of "1.0.0", and has a brief description "A simple Node.js application". The entry point of the application is "index.js" and it has two scripts "start" and "test". The dependencies of the application include "express" and "jest" as development dependencies. The author of the application is "John Doe" and the license is "MIT"

It is worth to note that this is just an example, you can add/remove properties as needed for your application.

How to include manifest json file in web application

To include a manifest.json file in a web application, you will need to add a link to the file in the HTML head of your application's index file. Here is an example of how to do this:

<!DOCTYPE html> 
 <link rel="manifest" href="/manifest.json"> 
 <!-- other head content --> 
 <!-- your application content --> 

This will include the manifest.json file in your application, and make it available to the browser.

Once the manifest is linked, the browser will download it and read it, it will use the information from the manifest file to configure and manage the web application. It can help the browser to install the web application as a standalone app, show the splash screen, change the theme color, etc.

It's worth to mention that it's not only necessary to include the manifest file but also to register a service worker, this allows to use some of the advanced features that a manifest provides, such as the ability to work offline.

It's also recommended to validate the manifest file before deploying to production, this can be done using the W3C validator, this will help you to avoid any error or compatibility issues.