Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/abhyudayasharma/react-git-info

Get Git commit information in your React App
https://github.com/abhyudayasharma/react-git-info

babel-plugin-macros create-react-app gatsby gatsbyjs git git-branch git-commit git-info git-tags hacktoberfest react typescript-support

Last synced: 11 days ago
JSON representation

Get Git commit information in your React App

Awesome Lists containing this project

README

        

# react-git-info

[![npm version](https://badge.fury.io/js/react-git-info.svg)](https://badge.fury.io/js/react-git-info)
![Node.js CI](https://github.com/AbhyudayaSharma/react-git-info/workflows/Node.js%20CI/badge.svg)

Get git commit information in your React Application as a JavaScript object.
No configuration necessary if you use create-react-app.

## Usage

You need to install this repository as an NPM `devDependency`:

```bash
npm install --save-dev react-git-info
```

After that you can import the information to your static React files.

```jsx
import GitInfo from 'react-git-info/macro';

const gitInfo = GitInfo();
console.log(gitInfo.branch);
console.log(gitInfo.tags);
console.log(gitInfo.commit.date);
console.log(gitInfo.commit.hash);
console.log(gitInfo.commit.message);
console.log(gitInfo.commit.shortHash);

// or from JSX

{gitInfo.commit.message}


```

### TypeScript Support

There is built-in TypeScript support, you won't have to install external types.

## How it works

This package uses a `babel-plugin-macros` macro that is preconfigured when
you're using a recent version of `create-react-app`.