{"id":419,"date":"2019-02-01T12:35:06","date_gmt":"2019-02-01T09:35:06","guid":{"rendered":"https:\/\/flatlogic.com\/blog\/?p=419"},"modified":"2024-02-23T17:57:48","modified_gmt":"2024-02-23T14:57:48","slug":"building-analytics-react-dashboard-with-cube-js","status":"publish","type":"post","link":"https:\/\/flatlogic.com\/blog\/building-analytics-react-dashboard-with-cube-js\/","title":{"rendered":"Building Analytics React Dashboard with Cube.js"},"content":{"rendered":"<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1024\" height=\"406\" data-src=\"https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2019\/01\/cubejs-flatlogic-cover-1024x406.png\" alt=\"\" class=\"wp-image-420 lazyload\" data-srcset=\"https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2019\/01\/cubejs-flatlogic-cover-1024x406.png 1024w, https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2019\/01\/cubejs-flatlogic-cover-600x238.png 600w, https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2019\/01\/cubejs-flatlogic-cover-768x304.png 768w, https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2019\/01\/cubejs-flatlogic-cover.png 1600w\" data-sizes=\"auto\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/406;\" data-original-sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p>Imagine that you need to <a href=\"https:\/\/flatlogic.com\/services\/web-development\">develop a web application<\/a> from scratch to monitor and analyze raw data. For example, you own an average size online store. You are not satisfied with the existing solutions for data analytics and you want to manage what components will be in your admin panel by yourself. It is also very important for you to work with raw data and build analytical charts yourself.<\/p><p>Often, you have to work with bulky libraries and write your own web application, which takes an enormous amount of time. The solution comes from Cube.js + <a href=\"https:\/\/flatlogic.com\">Flatlogic dashboards<\/a>.<\/p><p>The best way to start is to use one of&nbsp;<a href=\"https:\/\/flatlogic.com\/templates\/react\">Flatlogic React&#8217;s dashboards<\/a>&nbsp;and&nbsp;<a href=\"https:\/\/statsbot.co\/cubejs\/\">Cube.js<\/a>.<\/p><p><a href=\"https:\/\/github.com\/flatlogic\/ecommerce-dashboard-react\">The source code is available on Github here.<\/a><\/p><h2 class=\"wp-block-heading\">Let&#8217;s Build the Dashboard<\/h2><p>In this example, we will use the&nbsp;<a href=\"https:\/\/flatlogic.com\/templates\/sing-app-react\">Sing App React template<\/a>&nbsp;in order to eliminate steps of setting up a <a  data-ilj-link-preview=\"true\"  data-featured-image=\"https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2019\/09\/top-articles-copy-600x450.png\"  data-excerpt=\"Here is our list of JS articles of 2019. We collected 17 posts with tricks and tips in JavaScript and its frameworks.\" href=\"https:\/\/flatlogic.com\/blog\/17-articles-of-september-2019-to-learn-javascript\/\">react<\/a> environment from scratch and to have a dashboard interface from the beginning.<\/p><p>The first step is connecting your database with Cube.js. First of all, you need to <g class=\"gr_ gr_8 gr-alert gr_gramm gr_inline_cards gr_disable_anim_appear Style multiReplace\" id=\"8\" data-gr-id=\"8\">install&nbsp;<\/g><code>@cubejs-client\/core<\/code><g class=\"gr_ gr_7 gr-alert gr_gramm gr_inline_cards gr_disable_anim_appear Punctuation only-del replaceWithoutSep\" id=\"7\" data-gr-id=\"7\"><g class=\"gr_ gr_8 gr-alert gr_gramm gr_inline_cards gr_disable_anim_appear Style multiReplace\" id=\"8\" data-gr-id=\"8\">,<\/g>&nbsp;<\/g><code>@cubejs-client\/react<\/code><g class=\"gr_ gr_7 gr-alert gr_gramm gr_inline_cards gr_disable_anim_appear Punctuation only-del replaceWithoutSep\" id=\"7\" data-gr-id=\"7\">,<\/g> and recharts as a charts library. Then, you need to find the <a  data-ilj-link-preview=\"true\"  data-featured-image=\"https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2022\/01\/Cover-main-600x450.png\"  data-excerpt=\"An Application Programming Interface or API is a gateway that allows an App to communicate with other Apps and defines how that communication occurs.\" href=\"https:\/\/flatlogic.com\/blog\/what-is-api-and-how-api-works\/\">API<\/a> token in the project settings. After getting and installing all needed &#8220;equipment,&#8221; you have to import them into your react component and apply the API token.<\/p><pre class=\"wp-block-preformatted\"><code>1 import { LineChart, Line, XAxis, YAxis } from 'recharts';2 import cubejs from '@cubejs-client\/core';3 import { QueryRenderer } from '@cubejs-client\/react';45 const cubejsApi = cubejs(`api-token`); <a href=\"https:\/\/flatlogic.com\/generator\"><img decoding=\"async\" data-src=\"https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2025\/10\/Introducing-professional-vibe-coding.png\" alt=\"Professional Vibe Coding\" class=\"banner-img lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 2560px; --smush-placeholder-aspect-ratio: 2560\/640;\" data-srcset=\"https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2025\/10\/Introducing-professional-vibe-coding.png 2560w, https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2025\/10\/Introducing-professional-vibe-coding-600x150.png 600w, https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2025\/10\/Introducing-professional-vibe-coding-1024x256.png 1024w, https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2025\/10\/Introducing-professional-vibe-coding-768x192.png 768w, https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2025\/10\/Introducing-professional-vibe-coding-1536x384.png 1536w, https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2025\/10\/Introducing-professional-vibe-coding-2048x512.png 2048w\" data-sizes=\"auto\" data-original-sizes=\"(max-width: 2560px) 100vw, 2560px\"> <\/a><\/code><\/pre><p>Now you are ready to get any data you like. According to the docs, here&#8217;s how your component with chart should look:<\/p><pre class=\"wp-block-code wp-block-preformatted\"><code>1 &lt;QueryRenderer 2 query={{3 measures: &#91;'Stories.count'],4 dimensions: &#91;'Stories.time.month']5 }} 6 cubejsApi={cubejsApi} 7 render={({ resultSet }) =&gt; {8 if (!resultSet) {9 return 'Loading...';10 }1112 return (13 &lt;LineChart data={resultSet.rawData()}&gt;14 &lt;XAxis dataKey=\"Stories.time\"\/&gt;15 &lt;YAxis\/&gt;16 &lt;Line type=\"monotone\" dataKey=\"Stories.count\" stroke=\"#8884d8\"\/&gt;17 &lt;\/LineChart&gt;18 );19 }}20\/&gt;<\/code><\/pre><p><code>QueryRender<\/code>&nbsp;is the component from the Cube.js library. Let&#8217;s split it on in props.<\/p><p>The main property is&nbsp;<code>query<\/code>. There you can define what data to get from Cube.js.<\/p><p>You don&#8217;t have to know all Cube.js concepts to implement&nbsp;<code>query<\/code>&nbsp;because you can easily configure any query in Cube.js then export it in JSON format and paste it right into your&nbsp;<code>QueryRender<\/code>&nbsp;component.<\/p><p>The render property of&nbsp;<code>QueryRender<\/code>&nbsp;gets a function that returns whatever you want. In our case, we want to return the chart with already received data. The best feature is that you can return the loader while you are receiving data. Another lovely feature is the ability to export query data in different formats, like CSV or xlsx, right from the Cube.js dashboard.<\/p><p>Advantages<\/p><ul class=\"wp-block-list\"><li>Implementation speed and easy-to-understand API<\/li><li>Cube.js is visualization agnostic. This means you can use your favorite chart library, like Chart.js, Recharts, C3.js, or any other.<\/li><li>Cube.js Data Schema works as an ORM for your analytics. It allows you to model everything from simple counts to cohort retention and funnel analysis.<\/li><li>It is designed to work on top of your database, so all your data stays with you. All major SQL databases are supported.<\/li><\/ul><h2 class=\"wp-block-heading\">The Final Result<\/h2><p>Now with Cube.js and Flatlogic Dashboards, you can easily start your own web app with custom graphics and connect any database to visualize raw data. Here is an example using e-commerce data.&nbsp;<a href=\"https:\/\/demo.flatlogic.com\/cubejs-dashboard\">You can play with it here.<\/a><\/p><figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1024\" height=\"585\" data-src=\"https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2019\/01\/image-6-3-1024x585.png\" alt=\"\" class=\"wp-image-427 lazyload\" data-srcset=\"https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2019\/01\/image-6-3-1024x585.png 1024w, https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2019\/01\/image-6-3-600x343.png 600w, https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2019\/01\/image-6-3-768x439.png 768w\" data-sizes=\"auto\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/585;\" data-original-sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><em>Originally published at&nbsp;<\/em><a href=\"https:\/\/statsbot.co\/blog\/building-analytics-react-dashboard-with-cube.js\" rel=\"noreferrer noopener\" target=\"_blank\">https:\/\/statsbot.co\/blog\/building-analytics-react-dashboard-with-cube.js<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>Imagine that you need to develop a web application from scratch to monitor and analyze raw data. For example, you own an average size online store. You are not satisfied&#8230;<\/p>\n","protected":false},"author":3,"featured_media":435,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"flatlogic_tldr":"","flatlogic_facts":[],"footnotes":""},"categories":[1],"tags":[12,283,268,35],"class_list":["post-419","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news","tag-admin-template","tag-data-visualization","tag-flatlogic-generator","tag-reactjs"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.2 (Yoast SEO v26.2) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Building Analytics React Dashboard with Cube.js - Flatlogic Blog<\/title>\n<meta name=\"description\" content=\"This is a complete guide for building a React dashboard with Cube.js. Sing App template by Flatlogic is used as an example in this article.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/flatlogic.com\/blog\/building-analytics-react-dashboard-with-cube-js\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Building Analytics React Dashboard with Cube.js\" \/>\n<meta property=\"og:description\" content=\"This is a complete guide for building a React dashboard with Cube.js. Sing App template by Flatlogic is used as an example in this article.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/flatlogic.com\/blog\/building-analytics-react-dashboard-with-cube-js\/\" \/>\n<meta property=\"og:site_name\" content=\"Flatlogic Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/flatlogic\" \/>\n<meta property=\"article:published_time\" content=\"2019-02-01T09:35:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-23T14:57:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2019\/02\/12424.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Nastassia Ovchinnikova\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@flatlogic\" \/>\n<meta name=\"twitter:site\" content=\"@flatlogic\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nastassia Ovchinnikova\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Building Analytics React Dashboard with Cube.js - Flatlogic Blog","description":"This is a complete guide for building a React dashboard with Cube.js. Sing App template by Flatlogic is used as an example in this article.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/flatlogic.com\/blog\/building-analytics-react-dashboard-with-cube-js\/","og_locale":"en_US","og_type":"article","og_title":"Building Analytics React Dashboard with Cube.js","og_description":"This is a complete guide for building a React dashboard with Cube.js. Sing App template by Flatlogic is used as an example in this article.","og_url":"https:\/\/flatlogic.com\/blog\/building-analytics-react-dashboard-with-cube-js\/","og_site_name":"Flatlogic Blog","article_publisher":"https:\/\/www.facebook.com\/flatlogic","article_published_time":"2019-02-01T09:35:06+00:00","article_modified_time":"2024-02-23T14:57:48+00:00","og_image":[{"width":800,"height":600,"url":"https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2019\/02\/12424.jpeg","type":"image\/jpeg"}],"author":"Nastassia Ovchinnikova","twitter_card":"summary_large_image","twitter_creator":"@flatlogic","twitter_site":"@flatlogic","twitter_misc":{"Written by":"Nastassia Ovchinnikova","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/flatlogic.com\/blog\/building-analytics-react-dashboard-with-cube-js\/#article","isPartOf":{"@id":"https:\/\/flatlogic.com\/blog\/building-analytics-react-dashboard-with-cube-js\/"},"author":{"name":"Nastassia Ovchinnikova","@id":"https:\/\/flatlogic.com\/blog\/#\/schema\/person\/bed36c984b2f920a7fc450877f425eed"},"headline":"Building Analytics React Dashboard with Cube.js","datePublished":"2019-02-01T09:35:06+00:00","dateModified":"2024-02-23T14:57:48+00:00","mainEntityOfPage":{"@id":"https:\/\/flatlogic.com\/blog\/building-analytics-react-dashboard-with-cube-js\/"},"wordCount":519,"publisher":{"@id":"https:\/\/flatlogic.com\/blog\/#organization"},"image":{"@id":"https:\/\/flatlogic.com\/blog\/building-analytics-react-dashboard-with-cube-js\/#primaryimage"},"thumbnailUrl":"https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2019\/02\/12424.jpeg","keywords":["Admin Template","Data Visualization","Flatlogic Generator","React"],"articleSection":["News"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/flatlogic.com\/blog\/building-analytics-react-dashboard-with-cube-js\/","url":"https:\/\/flatlogic.com\/blog\/building-analytics-react-dashboard-with-cube-js\/","name":"Building Analytics React Dashboard with Cube.js - Flatlogic Blog","isPartOf":{"@id":"https:\/\/flatlogic.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/flatlogic.com\/blog\/building-analytics-react-dashboard-with-cube-js\/#primaryimage"},"image":{"@id":"https:\/\/flatlogic.com\/blog\/building-analytics-react-dashboard-with-cube-js\/#primaryimage"},"thumbnailUrl":"https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2019\/02\/12424.jpeg","datePublished":"2019-02-01T09:35:06+00:00","dateModified":"2024-02-23T14:57:48+00:00","description":"This is a complete guide for building a React dashboard with Cube.js. Sing App template by Flatlogic is used as an example in this article.","breadcrumb":{"@id":"https:\/\/flatlogic.com\/blog\/building-analytics-react-dashboard-with-cube-js\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/flatlogic.com\/blog\/building-analytics-react-dashboard-with-cube-js\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/flatlogic.com\/blog\/building-analytics-react-dashboard-with-cube-js\/#primaryimage","url":"https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2019\/02\/12424.jpeg","contentUrl":"https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2019\/02\/12424.jpeg","width":800,"height":600,"caption":"admin dashboard template"},{"@type":"BreadcrumbList","@id":"https:\/\/flatlogic.com\/blog\/building-analytics-react-dashboard-with-cube-js\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/flatlogic.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Building Analytics React Dashboard with Cube.js"}]},{"@type":"WebSite","@id":"https:\/\/flatlogic.com\/blog\/#website","url":"https:\/\/flatlogic.com\/blog\/","name":"Flatlogic Blog","description":"Vibe-coding, AI Agents, Professional Software Development Services, Case Studies and More","publisher":{"@id":"https:\/\/flatlogic.com\/blog\/#organization"},"alternateName":"Flatlogic Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/flatlogic.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/flatlogic.com\/blog\/#organization","name":"Flatlogic","url":"https:\/\/flatlogic.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/flatlogic.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2025\/10\/62ea6de0b3469aa3d6ebb528-1.png","contentUrl":"https:\/\/flatlogic.com\/blog\/wp-content\/uploads\/2025\/10\/62ea6de0b3469aa3d6ebb528-1.png","width":970,"height":257,"caption":"Flatlogic"},"image":{"@id":"https:\/\/flatlogic.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/flatlogic","https:\/\/x.com\/flatlogic","https:\/\/www.instagram.com\/flatlogiccom\/","https:\/\/www.linkedin.com\/company\/flatlogic\/"]},{"@type":"Person","@id":"https:\/\/flatlogic.com\/blog\/#\/schema\/person\/bed36c984b2f920a7fc450877f425eed","name":"Nastassia Ovchinnikova","url":"https:\/\/flatlogic.com\/blog\/author\/nastassia\/"}]}},"_links":{"self":[{"href":"https:\/\/flatlogic.com\/blog\/wp-json\/wp\/v2\/posts\/419","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/flatlogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/flatlogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/flatlogic.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/flatlogic.com\/blog\/wp-json\/wp\/v2\/comments?post=419"}],"version-history":[{"count":4,"href":"https:\/\/flatlogic.com\/blog\/wp-json\/wp\/v2\/posts\/419\/revisions"}],"predecessor-version":[{"id":15095,"href":"https:\/\/flatlogic.com\/blog\/wp-json\/wp\/v2\/posts\/419\/revisions\/15095"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/flatlogic.com\/blog\/wp-json\/wp\/v2\/media\/435"}],"wp:attachment":[{"href":"https:\/\/flatlogic.com\/blog\/wp-json\/wp\/v2\/media?parent=419"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/flatlogic.com\/blog\/wp-json\/wp\/v2\/categories?post=419"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/flatlogic.com\/blog\/wp-json\/wp\/v2\/tags?post=419"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}