DEV Community

Cover image for How to Build A Feed App With React and Tailwind CSS
Oyetoke Toby
Oyetoke Toby

Posted on

How to Build A Feed App With React and Tailwind CSS

A feed app is a simple app that curates the latest news and articles all over the web and different sources.

So in this article, I will explain how to simply create one using React, Tailwind CSS and my Feed API ( At the end of this article, we'll be able to build something similar to this -

If you want a live and hands-on experience, you can follow the video below:

Subscribe to my channel here:

If you are not able to watch the video, you can simply continue reading on below.


  1. CRA (react)
  2. Axios (http)
  3. Tailwind CSS (CDN) (not necessary)

Setting Up Our Project

The first step here is to set up our react project using Create-React-App. If you don't have it installed, you can read about the installation process here.

To create our app, simply run the command below:

$ npx create-react-app feed-app

After successfully creating our CRA app, let's get into other setups.

Navigate to the src folder in the main directory and create:

  1. A components folder. Then in the components folder, create three files (sidebar.js, main.js, articles.js).
  2. a config.js file
$ mkdir components
$ touch config.js components/sidebar.js components/main.js components/articles.js

The next thing is to add the Tailwind CSS to your project. There are many ways to do this, but the easiest and fastest way is to use the CDN. You can head over here to get the CDN or simply use the one below:

<link href="^1.0/dist/tailwind.min.css" rel="stylesheet">

Now in the public folder, open the index.html and update it with the Tailwind CSS.

Feed API - Understanding How Medrum API Works

Before we proceed into coding and the next phase of the project, let's try to understand how the Feed API works. Medrum is built using Python, BeautifulSoup, and Scrapy to scrape articles, news and other various things on the internet.

Medrum has two endpoints, articles and feeds. In articles, you can't really specify which source you want to read from, but you can from feeds.

Basically, to get latest articles, you can send a request to this endpoint - which would return something like below:

[{"title": "Juno Makes Writing Julia Awesome", "url": "", "comment_url": null, "ago": "3h", "date": "2020-02-02 04:06:09AM UTC"}, {"title": "Introducing Leya: The Meta-Statistical Lisp-like language", "url": "", "comment_url": null, "ago": "8h", "date": "2020-02-01 11:26:32PM UTC"}, {"title": "Transform Reality with Pandas", "url": "", "comment_url": null, "ago": "10h", "date": "2020-02-01 09:34:26PM UTC"}, {"title": "Using Stringr and Regex to Extract Features from Textual, Alphanumeric  and Punctuation Data in R", "url": "", "comment_url": null, "ago": "13h", "date": "2020-02-01 06:31:13PM UTC"}, {"title": "Getting Browser User Permission with the Permissions API", "url": "", "comment_url": null, "ago": "15h", "date": "2020-02-01 04:03:06PM UTC"}, {"title": "Get More Out of Google Colab", "url": "", "comment_url": null, "ago": "16h", "date": "2020-02-01 03:34:54PM UTC"}]

You can filter the intervals of the articles scraped. It can either be latest, day, week, month. For instance, you can get all articles posted this week using -

To be able to get a feed, you must specify a source id, which can be found here -

To get feeds, you'd need to use the source id (5bbb1af8af62ff6841b4b26e) in the combination below:

You can filter the endpoints using page and sort (popular, latest).

Cool right and it's free to use.

You can support me on Patreon - to continue building free APIs

Building Our Feed Application

Now that we have understood how the API works, let's see how to incorporate this into our app.

Open the config.js file:

export const SOURCES_URL = ""
export const FEEDS_URL = ""

This contains the two endpoints we'll be using in our application.

Now open the main.js file and paste the below:

import React, { useState, useEffect } from "react";

import Sidebar from "./sidebar";
import Articles from "./articles";
import { SOURCES_URL, FEEDS_URL } from "../config";

import axios from "axios";

function Main() {
  const [sources, setSources] = useState([]);
  const [articles, setArticles] = useState([]);
  const [source, setSource] = useState([]);

  const fetchSource = id => {
    axios.get(`${FEEDS_URL}?source=${id}`).then(res => {
  useEffect(() => {
    axios.get(SOURCES_URL).then(res => {
  }, []);
  return (
    <div className="flex">
      <div className="w-1/4 bg-gray-500 p-3">
        <Sidebar source={source} sources={sources} fetchSource={fetchSource} />
      <div className="w-3/4 bg-gray-400 p-3">
        <Articles articles={articles} />

export default Main;

Here's what we did above:

  1. We imported our Sidebar and Articles components
  2. We added three useState hooks - sources, articles, source
  3. We created a function-fetchSource: This will be used in getting a source feeds.
  4. We added a useEffect hooks: This will get the available sources we can get their feeds and also loads a source feed by default.
  5. We passed the source, sources and fetchSource to the Sidebar component and articles to the Articles components as props

The next thing is to open the sidebar.js component:

import React from "react";

function Sidebar({ sources, fetchSource, source }) {
  if (!sources.length) return <p>Loading...</p>

  return (
      {, k) => {
        if (s.contentType!=="news") return null;
        return (
style={{background: ? "#ccc": "transparent"}}
            onClick={() => {

export default Sidebar;

The above is actually very easy to understand, but here's the breakdown:

  1. Show loading if the sources prop is empty
  2. Map through the sources prop, check if the contentType of the current source is news, then display the name, add an onClick event to call fetchSource with the source id as param and add a background if the current source id is the active source id.

The next thing now is to open the articles.js file:

import React from "react";

function Articles({ articles }) {
  if (!articles.length) return <p>Loading...</p>

  return (
      {, k) => {
        return (
          <p className="mb-4" key={k}>
            <a href={a.url} target="_blank">{a.title}</a>

export default Articles;

In this we didn't do anything much, we only mapped through the articles prop to display all the feeds.

The last thing to do is to import our main.js component in app.js file:

import React from "react";
import "./styles.css";
import Main from "./components/main";

function App() {
  return (
    <div className="wrapper">

That's it! If everything goes well, you should see something like below:

Screen Shot 2020-02-02 at 9.29.12 AM.png

That's all. You can check out a live demo here: You can check out the code on code sandbox here:

Don't forget to share to others and if you want to support me here's my Patreon:

Top comments (0)