# Is there a way to like a post for a user and display it?

**URL:** <https://forum.ghost.org/t/is-there-a-way-to-like-a-post-for-a-user-and-display-it/13115>\
**Category:** Using Ghost\
**Created:** [March 31, 2020, 8:21am UTC](https://forum.ghost.org/t/is-there-a-way-to-like-a-post-for-a-user-and-display-it/13115 "2020-03-31T08:21:15Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fabian\_Starke](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/fabian_starke/32/7097_2.png) [@Fabian\_Starke](https://forum.ghost.org/u/Fabian_Starke)\
**Post date:** [March 31, 2020, 8:21am UTC](https://forum.ghost.org/t/is-there-a-way-to-like-a-post-for-a-user-and-display-it/13115/1 "2020-03-31T08:21:15Z")

</div>

Hi,

I am looking for a simple integration that would count likes of blog users.  
I provide here an image of what I am trying to achieve.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/0/06773e7020cdb9ab8dcfa91b0f9cb7ba3477baf2.png)

It would just be a module where user can add a like to a post.

Thank you for the help

---

<div class="post-metadata">

**Author:** ![DavidDarnes](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/daviddarnes/32/3533_2.png) [@DavidDarnes](https://forum.ghost.org/u/DavidDarnes)\
**Post date:** [March 31, 2020, 10:17am UTC](https://forum.ghost.org/t/is-there-a-way-to-like-a-post-for-a-user-and-display-it/13115/2 "2020-03-31T10:17:11Z")

</div>

Maybe you could repurpose this library called ‘Applause’ which mimics the claps feature shown on Medium: [https://applause-button.com/](https://applause-button.com/)

---

<div class="post-metadata">

**Author:** ![Fabian\_Starke](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/fabian_starke/32/7097_2.png) [@Fabian\_Starke](https://forum.ghost.org/u/Fabian_Starke)\
**Post date:** [March 31, 2020, 12:38pm UTC](https://forum.ghost.org/t/is-there-a-way-to-like-a-post-for-a-user-and-display-it/13115/3 "2020-03-31T12:38:33Z")

</div>

Thanks for the suggestion. I have to see if I can integrate it and change the button to be a heart instead !

---

<div class="post-metadata">

**Author:** ![janmueller](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/janmueller/32/2963_2.png) [@janmueller](https://forum.ghost.org/u/janmueller)\
**Post date:** [May 2, 2020, 1:21pm UTC](https://forum.ghost.org/t/is-there-a-way-to-like-a-post-for-a-user-and-display-it/13115/4 "2020-05-02T13:21:45Z")

</div>

Did you manage to get it to work?

Actually it would be a really nice addition to ghost. With Wordpress it’s as easy as installing a plugin to get it into your site. Up & running in no time.

---

<div class="post-metadata">

**Author:** ![Fabian\_Starke](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/fabian_starke/32/7097_2.png) [@Fabian\_Starke](https://forum.ghost.org/u/Fabian_Starke)\
**Post date:** [May 4, 2020, 7:23am UTC](https://forum.ghost.org/t/is-there-a-way-to-like-a-post-for-a-user-and-display-it/13115/5 "2020-05-04T07:23:46Z")

</div>

@janmueller Finally I implemented the `applause-button` as it was suggested, I had to rewrite component in React, I didn’t find any other library or simple way to integrate it ! As you said this is really a feature that is missing and should be implemented for sure.

---

<div class="post-metadata">

**Author:** ![janmueller](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/janmueller/32/2963_2.png) [@janmueller](https://forum.ghost.org/u/janmueller)\
**Post date:** [May 4, 2020, 10:17am UTC](https://forum.ghost.org/t/is-there-a-way-to-like-a-post-for-a-user-and-display-it/13115/6 "2020-05-04T10:17:51Z")

</div>

hmm… so do you have a version that can be integrated into ghost?

---

<div class="post-metadata">

**Author:** ![Fabian\_Starke](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/fabian_starke/32/7097_2.png) [@Fabian\_Starke](https://forum.ghost.org/u/Fabian_Starke)\
**Post date:** [May 4, 2020, 10:53am UTC](https://forum.ghost.org/t/is-there-a-way-to-like-a-post-for-a-user-and-display-it/13115/7 "2020-05-04T10:53:36Z")

</div>

As I said I made a react component that is connected to the `applause-button` library. It is a third party free service. For our implementation it was ok for us to use that king of library. This way was easier and quicker to implement than adding a table to the ghost database and connecting it to our backend. As it is only the number of likes we do not need to store in our database. The API gives you the number of likes per article and there is also another endpoint where you can get likes from different url’s.

---

<div class="post-metadata">

**Author:** ![victor-sopot](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/victor-sopot/32/17943_2.png) [@victor-sopot](https://forum.ghost.org/u/victor-sopot)\
**Post date:** [November 1, 2020, 8:24pm UTC](https://forum.ghost.org/t/is-there-a-way-to-like-a-post-for-a-user-and-display-it/13115/8 "2020-11-01T20:24:36Z")

</div>

Sounds great I would love to see some code in action on this.

---

<div class="post-metadata">

**Author:** ![Fabian\_Starke](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/fabian_starke/32/7097_2.png) [@Fabian\_Starke](https://forum.ghost.org/u/Fabian_Starke)\
**Post date:** [November 5, 2020, 5:58pm UTC](https://forum.ghost.org/t/is-there-a-way-to-like-a-post-for-a-user-and-display-it/13115/9 "2020-11-05T17:58:36Z")

</div>

Unfortunately I cannot give access to this private repo but i can share the component i created in my app

```auto
/* eslint-disable react/prop-types */
import React, { useState, useEffect } from "react"
import '../../styles/likeButton.scss'
import axios from "axios"
import { withPrefix } from 'gatsby'

const API = `https://api.applause-button.com`
const VERSION = `3.3.0`
const mainUrl = `https://lemonads.com/`

const HEADERS = {
    "Content-Type": `text/plain`,
}

const getClaps = async (url) => {
    const query = url ? `?url=${url}` : ``
    return await axios.get(`${API}/get-claps${query}`, {
        headers: HEADERS,
    })
}

const updateClaps = async (url, claps = 1) => {
    console.log(claps)
    const query = url ? `?url=${url}` : ``
    return await axios.post(`${API}/update-claps${query}`,
        JSON.stringify(`${claps},${VERSION}`), {
            headers: HEADERS,
        })
}

const LikeButton = ({ url = mainUrl }) => {
    const [count, setCount] = useState(0)
    const [isClapped, setIsClapped] = useState(false)
    const doApplause = () => {
        if (!isClapped) {
            console.log(`do clapping`)
            const callBackend = async () => {
                const result = await updateClaps(url, 1)
                setCount(result.data)
                setIsClapped(true)
            }
            callBackend()
        }
    }

    useEffect(() => {
        const fetchData = async () => {
            const result = await getClaps(url)
            console.log(result)
            setCount(result.data)
        }
        fetchData()
    }, [])

    return (
        <div className="like-button" onClick={doApplause}>
            <div>
                <img src={withPrefix(`/assets/img/like.svg`)} />
                {count > 0 && 
                    <div className="count-container" >
                        {<div className="count">{count}</div>}
                    </div>
                }
               
            </div>

        </div>
    )
}

export default LikeButton

```

And than I used it in the post template, I just had to pass the url prop.  
Hope it helps !

---

<div class="post-metadata">

**Author:** ![amgrammer](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/amgrammer/32/19606_2.png) [@amgrammer](https://forum.ghost.org/u/amgrammer)\
**Post date:** [September 25, 2022, 6:04pm UTC](https://forum.ghost.org/t/is-there-a-way-to-like-a-post-for-a-user-and-display-it/13115/10 "2022-09-25T18:04:54Z")

</div>

I’ve got something in the works that should be ready to start testing soon. If you are interested in being part of the test group let me know on Twitter or email!

Twitter: @amgrammer  
Email: [usual.zone3165@fastmail.com](mailto:usual.zone3165@fastmail.com) (yes the email is weird looking. This is not a scam. I’m using a masked email since this is a public forum)
