Skip to main content

Command Palette

Search for a command to run...

Introducing Hashnode to Twitter

Post bite-sized tweets of your Hashnode blog post to increase reach ๐Ÿš€ ๐Ÿš€

Updated
โ€ข6 min read
Introducing Hashnode to Twitter
S

Software Engineer @ Microsoft | Ex-Dell, JLL, Hasura | Google Certified MWS | Google India Scholar '18 | Full stack dev | 600K+ views on blogs

Introduction

Hey folks ๐Ÿ‘‹

I am really glad to present to you Hashnode to Twitter application, which is my submission for Hashnode X Auth0 Hackathon. A big thanks to Auth0 and @Hashnode for giving me this opportunity to sharpen my dev skills. ๐Ÿ’ช

Live Application / Source Code

Inspiration ๐Ÿค”

The Problem

I have noticed many developers starting their blogs but failing to get substantial eyeballs on their post. Hashnode surely helps in this case by mapping it to one's personal custom domain for free, and get readership by showing one's articles directly to the feed of many developers. It also drives traffic to one's blog domain directly.

But still, social media is one of the most important driving factors for the success of one's blog. We all have seen various developer tweet threads go viral.

The Solution

So, I decided to build a tool which takes the content from your blog and directly tweets on your behalf. The tweets would be customizable with hashtags, emojis and all the Twitter goodness!

What exactly is "Hashnode to Twitter"โ“

Hashnode to Twitter is a web application which allows you to convert your Hashnode article summary to easy-to-consume tweet threads with a CTA to your blog post. This will help you to increase the popularity of your blogs and bring more eyeballs.

Features

Video Demo

  • Login Screen

auth0-cropped.png The user needs to login via Twitter as the application would post on his behalf to Twitter. On clicking "Continue with Twitter" on the Auth0 login screen, the page redirects to twitter's authorization page:

twitter-auth-cropped.png

  • Extract content from Hashnode blog post URL

screenshot-20210831-021248.png On the homescreen, the user is presented with a URL input where he can enter the link to a Hashnode blog post. Upon logging in via Twitter, he can see the article content split up into tweet-sized chunks.

  • Edit tweets and make a thread ๐Ÿงต

edit-screen.png Threads are one of the most popular forms of content on Twitter. In the Edit screen, the user can see the Hashnode article split into tweets of 280 or less characters. User can delete one or more tweets, edit the content of the tweets. There is also a popular hashtags and emojis section from where he can pick the popular hashtags and emojis to use in the tweets. All of these tweets will be converted into a thread.

edit last tweet.png A last tweet is automatically added to encourage readers to go to the Hashnode blog article.

  • View rich, realtime, exact preview of tweets

preview part.png While editing the tweets and making the twitter thread, the user will be able to see a realtime preview of his tweets in the right side panel. All texts, mentions, links, hashtags, emojis are the exact same as one would see after actually tweeting. After the user is happy with the twitter thread's contents, he can click on the Tweet button to start tweeting the thread via his logged-in Twitter account.

  • Success page

done-screen.png After clicking the Tweet button on the edit page, the tweet thread is posted from his Twitter account. On successful posting of all the tweets in the thread, the user is sent to the success/done page where all the actual tweets from Twitter are embedded. He can also click to view his tweet(s) in a new tab.

How I Built It ๐Ÿ› 

Tech Stack Overview

Framework

I chose Next.js for my frontend framework because it makes it so easy to build a working app with its file-system routing, image optimization. It also has all features like Static Site Generation, Server Side Rendering and Client Side rendering and the developer has the choice to choose any of these, on a per-page basis.

Another reason I chose Next.js is because of its support for API routes which I have used for creating serverless functions. I call these functions from my frontend and use their responses.

Authentication

For auth, I used Auth0. And this was my first time using Auth0 with Next.js. And boy was I surprised! I literally had to add 2 lines in API routes to make my app authenticated and I could get the user's details in my frontend using the useUser hook. It was brilliant!

import { handleAuth } from '@auth0/nextjs-auth0';

export default handleAuth();

The docs were super-helpful in order to add Twitter as a Social Authentication method.

For my app, I needed write access to a user's Twitter profile as my app would be posting on their behalf. So, I needed to call the Twitter API with the logged-in user's context. For this, I used the Auth0 Management API Tokens. This helps me access the Twitter API with the user's Twitter account.

tmpgu0YxQ.png

This was quite new for me so I had fun learning this.

CSS Framework

I used my all-time favorite CSS framework - Tailwind CSS. Now-a-days, I can't even imagine starting a project without using Tailwind. The utility classes, pseudo selectors are quite handy if one is looking to build out a frontend quickly.

Version Control

I used GitHub as my version control so that I could roll back to any previous commit as and when required.

Deployment

I chose Vercel for deploying my app as it has first-class support for Next.js and its API routes. So, it was a no-brainer choice.

Lighthouse score

This is the lighthouse score of the app in an incognito window:

screenshot-20210831-113129.png

What I learned & challenges faced

I learnt a lot of new things while developing this application.

  • The first thing which I learnt is: I normally decide on the idea of an application and a lot of the effort is wasted on make auth work. Instead, I have used Auth0 for the first time in an actual app and I can feel the weight lifted from my shoulders. And the integration with Next.js is amazing.
  • I used the Twitter API from a user's context for the first time. This enables the app developer to post tweets, reply to tweets and do other things as the user. This was also very easily done with Auth0.

I also faced some challenges along the way.

  • One of the most time-taking challenge I faced was: showing the meta image of links in the Twitter card on the Edit/Preview page. I tried to use unfurl.js but I was getting CORS error. So, I decided to proxy the request via an API route and I was successful in fetching the meta image of any link.
  • In order to show the correct preview of tweet mentions, hashtags and URLs to be blue in color and link to the correct destinations, I had to extract them manually from the text the user had entered. I was confused as how to do this elegantly. Luckily, I found twitter-text which helped me in this immensely.

What's next for "Hashnode to Twitter"

  • Add functionality to upload code blocks automatically to carbon.now.sh and add them to tweets.
  • Make use of AI (GPT-3 or others) to generate/optimize tweets for more readers.
  • Add posting to other social media as well like Facebook, Instagram, LinkedIn.

Try it Out

Please try this out and give your valuable feedback in the comments below or on Twitter.

Again thanks to Auth0 and @Hashnode for this amazing opportunity!

Comments (15)

Join the discussion
A

Wow this has so much potential!

10
S

Thank you so much! I am planning to update it with more features!

J

So incredible. I'd love to follow up send you some Auth0 swag, and chat more about the app!

10
S

Hey James!! Thanks for reaching out! ๐Ÿ˜Š Replied to your DM on Twitter ๐Ÿ™.

M

Amazing Project Soumya Ranjan Mohanty. Very useful for beginners like me.

10
S

Hey Monikinderjit Singh, glad that you found it useful!

Thank you for your kind words. ๐Ÿ˜Š

9
I

This is pretty awesome sincerely Soumya Ranjan Mohanty Good job

10
S

Thank you so much Olubisi Idris Ayinde! ๐Ÿ˜Š

N

Too good bruh..!! ๐Ÿ˜

10
S

Thanks Nitin!

S

Great work Soumya Ranjan Mohanty, Keep it up ๐Ÿ‘ I was looking for some open source project to learn more about twitter API and this is the best. Keep up the good work ๐Ÿ™Œ

9
S

Hey Savio Martin. Thanks for your kind words about the project :)

Love your back-to-back rocking projects! Keep it up! ๐Ÿ™Œ

10
K

This is excellent. Great work.

10
S

Hey Kritika Pattalam Bharathkumar! Thanks a lot for your kind words. :)

1
E

Wow, that's amazing Soumya Ranjan Mohanty! I like that you can customize the tweets.

I'll start using it for my own articles :)

10
S

Thanks a ton Eleftheria Batsou!

Really glad you find my application of use. :)

R

Really cool idea and execution as well. Great job ๐Ÿ™Œ

10
S

Hey Rutik Wankhade, thank you for your kind words. Glad you liked the app.

A

Soumya Ranjan Mohanty I am telling you this is everything I needed right now. Amazing Idea and Implementation and specially the live changes we can see while editing was something to be appreciated. All the best buddy you did a great work totally gonna use it from now on.

10
S

Hey Ashish maurya, this comment made my day! Thanks for your kind words. Really hope you find this useful ๐Ÿ˜„.

1
A

Soumya Ranjan Mohanty you welcome buddy, and believe me I am already using this app for my next blog posts.

10