Nikhil Goyal
Nikhil Goyal

Reputation: 1973

Use package.json data in HTML ReactJS

I have a scenario where I want to use name from package.json in my HTML so that I can use it as the title of the document.

I know it can be done using react-helmet but the organization doesn't allow to install that package. Is there any other way to do the same?

Upvotes: 0

Views: 1170

Answers (1)

Arshpreet Wadehra
Arshpreet Wadehra

Reputation: 1023

You can import package.json file directly in your js or jsx file.

import packageJson from '<root-path-of-project->/package.json';

const { name } = packageJson;

Upvotes: 1

Related Questions