Skip to content

Bunlong/next-timeago

Repository files navigation

next-timeago

React timeago component for your next React apps.

NPM JavaScript Style Guide

🎁 Features

  • No dependencies
  • Compatible with both JavaScript and TypeScript
  • Support for various languages

🔧 Install

next-timeago is available on npm. It can be installed with the following command:

npm install next-timeago --save

next-timeago is available on yarn as well. It can be installed with the following command:

yarn add next-timeago --save

💡 Usage

import { useTimeAgo } from 'next-timeago';

const Home = () => {
  const { TimeAgo } = useTimeAgo();

  return (
    <>
      <TimeAgo date='July 1, 2023' locale='kh' />

      <TimeAgo date='July 1, 2023' locale='JA' />

      <TimeAgo date='July 1, 2023 9:00 pm' />

      <TimeAgo date='July 1, 2023 20:00' />
    </>
  );
}

export default Home;

Props

Prop Type Default Require Description
date string | number | Date ✔️ A date in the past.
locale string en Support for various languages.
live boolean true Live by default and will auto update it's value.
element string | React.ElementType time HTML tag that is used to wrap the live updating string.

List of Locale Codes

Language Name Code
Afrikaans af
Arabic ar
Azerbaijani az
Azerbaijani shortened az-short
Belarusian be
Bulgarian bg
Bosnian bs
Catalan ca
Czech cs
Welsh cy
Danish da
German de
German shortened de-short
Divehi, Dhivehi, Maldivian dv
Greek el
English en
English shortened en-short
Spanish es
Spanish shortened es-short
Estonian et
Basque eu
Persian fa
Persian shortened fa-short
Finnish fi
French fr
French shortened fr-short
Galician gl
Hebrew he
Hindi hi
Croatian hr
Hungarian hu
Armenian hy
Indonesian id
Icelandic is
Italian it
Italian shortened it-short
Japanese ja
Javanesse jv
Georgian jv
Georgian shortened ka-short
Khmer kh
Korean ko
Russian ky
Lithuanian lt
Latvian lv
Macedonian mk
Dutch nl
Norwegian no
Catalan oc
Polish pl
Portuguese pt
Brazilian Portuguese pt-br
Portuguese Brasil shortened pt-br-short
Portuguese shortened pt-short
Romanian ro
Serbian rs
Russian ru
Kinyarwanda rw
Sinhalese si
Slovak sk
Slovenian with support for dual sl
Somali so
Serbian sr
Swedish sv
Tamil ta
Thai th
Turkish tr
Turkish shortened tr-short
Ukrainian uk
Uzbek uz
Vietnamese vi
Simplified Chinese zh-CN
Traditional Chinese, zh-tw zh-TW

📜 Changelog

Latest version 0.2.0 (2023-08-23):

  • Upgrade dependencies

Details changes for each release are documented in the CHANGELOG.md.

❗ Issues

If you think any of the next-timeago can be improved, please do open a PR with any updates and submit any issues. Also, I will continue to improve this, so you might want to watch/star this repository to revisit.

💪 Contribution

We'd love to have your helping hand on contributions to next-timeago by forking and sending a pull request!

Your contributions are heartily ♡ welcome, recognized and appreciated. (✿◠‿◠)

How to contribute:

  • Open pull request with improvements
  • Discuss ideas in issues
  • Spread the word
  • Reach out with any feedback

🏆 Contributors

Bunlong
Bunlong

⚖️ License

The MIT License License: MIT