Best 19 JavaScript Charts Libraries

How to choose the right javascript charting library? Top javascript charting libraries Conclusion About Flatlogic

JavaScript Charting Libraries: Introduction

In today’s world, people are struggling more and more with the problem of scattered attention. So it is becoming more and more important to present information in a structured, interesting, and well-designed way, especially if you have a complex business application. Presenting huge chunks of data in a standard spreadsheet to analyze or to study is as inconvenient as it can get. Creating different charts and JavaScript charting in particular is a big issue that we will consider.

Javascript charts are an essential part of a web application for presenting data. It means JavaScript charting libraries are inevitable. The way the human brain itself is programmed is that it understands visual data much better than anything else. Well visualized data creates much more influence than the data being presented as it is, no matter how well it is explained.

Companies build strategies around the charts, numbers, and tables they’re presented with, and often use them to choose whether to pursue business opportunities. It is very important to choose the right tool to build a workaround.

But how do you choose the tool that will fit your requirements in the javascript technology zoo? How to choose the right graphics for your data? Should it be paid or free? Build your own solution or take a ready-made tool?

We will try to cover all these questions in this guide. First, we will talk about how to choose the right javascript charting library. Then we will define the criteria for evaluating the tools, and finally, compare the most popular javascript charts on the market.

How to choose the right javascript charting library?

When you approach the choice of the chart js library, everything is highly individual and depends on many criteria. Therefore, in this section, we will consider things you should pay attention to while choosing the tools for drawing charts.

There are quite a few javascript charting libraries around now, but which are the best to use? This can depend on many factors like business needs, types of data, the purpose of the chart itself and many more.

A nice interface and copy/paste code are all well and good if we need something generic to our needs. But frankly speaking, most of the time we actually need something tailored to our use case. Even more than that  –  we need a reliable charting library we could build upon.

There are several factors to consider here:

What kind of charts does the company want to build? Pie charts, maps, lines, bars? How large is the dataset? Is the app going to be used for Web, mobile, or both? SVG or Canvas base? Libraries based on SVG are usually better for smaller to medium datasets, as each element is a unique node and exists in the DOM tree. On the other side, Canvas is really fast. What is the browser support for a given library? Check your browser market share to figure this out. Which JavaScript framework do you use? What kind of customization of the look and feel do you need?

Note that in some cases you may not need a data visualization library at all. Sometimes it’s better just to write one from scratch using vanilla JavaScript.

Here is an example of a decision diagram that I have found on the internet

Top JavaScript Charting Libraries

In this article, each JavaScript charting library will be compared with some key factors including chart types, commercial or free, and open-source status. These beautiful libraries have been analyzed thoroughly with hands-on experience to maximize the very best comparison.

Highcharts

License: Free for non-commercial, paid for commercial
Price: Free to $7060
Main dependencies: No dependencies
Web-site: https://www.highcharts.com/

HighCharts a modern javascript charting library based on SVG technology. It doesn’t require any plugin. The integration with all of the major web frameworks is very simple.

In all of its simplicity, Highcharts is also very much compatible with old browsers, so you can pick it if you don’t need to represent data using advanced charting styles.

Notable Features:

Optimized for both responsive design and touch devices; Capable of working with Big Data; On-hover tooltips rendering is super-quick; Ability to annotate graphs; Data can be loaded to charts directly from a CSV file.

Highcharts allows you to configure the theme separately from the data. This allows you to have a common theme for your brand to apply across all the charts on your website. 

Highcharts is extensively documented and has most use cases covered. 

HighCharts is used by some major companies across the world, including Facebook, IBM, MasterCard, and StackOverflow. It’s probably the most advanced library out there regarding types of charts available, but of course, comes at a cost for commercial use. If the pricing is not a stumble, Highcharts is an excellent choice.

Chartist-js

License: Open-source
Price: Free
Main dependencies: No dependencies
Web-site: http://gionkunz.github.io/chartist-js/

Chartist is a very modern, SVG based library. Its biggest feature is the SVG animations in the charts produced with this library.

It has a solid technology base and is very easy to implement. Within minutes you can make an incredibly impressive chart that interacts easily with any backend data source. Chartist is really easy to configure, as well as easy to customize with Sass.

This library has only 8 base chart types which can be used to improvise over a few more different types. Each is fully responsive but doesn’t have a great transitional effect as others.

Features:

Filtering by labels; Click on a legend to show and hide data on the chart; Non-numeric Y-Axis, have labels instead; Easy customization with interpolation of line charts.

The Chart.js visualization library is completely open-sourced with the MIT License and available to modify, distribute, and use. Source files are available to ‘fork’ on GitHub too.

Chart.js offers a vast documentation base including precise instructions on installing the library. The library can be quickly installed with Bower, NPM, jsDelivr, and can even be linked up from CDNJS. Besides, you can download the source files directly from the GitHub Repo.

Chartist is a very powerful charting library, but it requires more work on the developer’s end to get things to look right.

C3.js

License: Open-source
Price: Free
Main dependencies: D3.js
Web-site: https://c3js.org/

C3 is a very efficient D3 based chart visualization library. C3 library is fast to render, has good compatibility across browsers, and is very simple to integrate. If you’re looking for no-frills, C3 is a decent choice.

It also includes good documentation for what is an inherently simple library.

Features:

Extensive tutorials and documentation; Responsive and mobile-ready; Stylish tooltips already integrated; Filterable data series.

C3 provides a getting started guide that instructs on how to get the basic library setup with your project.

Chartjs

License: Open-source
Price: Free
Main dependencies: Moment.js
Web-site: https://www.chartjs.org/

The Chart js is an HTML5 based JavaScript library for creating animated, interactive, and customizable charts and graphs. Chart.js is a much lighter product than HighCharts and doesn’t offer quite as much choice.

The Chart.js API is fairly simple and well-documented. Chart.js uses canvas instead of SVG. The library is actively maintained and has a few plugins to extend its functionality.

Chart.js offers 8 different chart types for data visualization with out-of-the-box animations. It is compatible with all modern browsers. Also, the responsive chart behavior of the charts can be enabled by some configuration.

Plotly

License: Open-source
Price: Free, paid for enterprise
Main dependencies: D3.js, Stack.gl
Web-site: https://plot.ly/

Plotly is one of the most common libraries around. Plotly is a very rich library and has outstanding documentation, including a tutorial for each of the chart types.

It has been open-source since 2015, meaning anyone can use it for free. Plotly.js supports 20 chart types, including SVG maps, 3D charts, and statistical graphs. It’s built on top of D3.js and stack.gl.

The charts and graph types available have a professional look and feel. Creating a chart is just a matter of loading in your information and customizing the layout, axes, notes, and legend.

NVD3

License: Open-source
Price: Free, paid for enterprise
Main dependencies: D3.js
Web-site: http://nvd3.org/

NVD3 is also on the list of the most popular libraries. Built upon D3.js like the others above, it does have a solid technical base.

The performance is relatively good, and it does have basic animations to inject some visual stimulation in an otherwise fairly plain interface. Data can be pumped directly from .json files, meaning NVD3 is very easy to integrate with existing data API solutions.

When compared to other libraries on this list, it looks rather small with many charts not available, but most of the general graph-types are present.

This visualization library is completely open-sourced with the Apache 2.0 License.

Fusion Charts

License: Paid
Price: From $497
Main dependencies: No dependencies
Web-site: https://www.fusioncharts.com/

FusionCharts probably has the most complete collection of charts and maps. With over 90+ chart types and 965 maps, you’ll find everything that you need right out of the box.

FusionCharts supports both JSON and XML data formats, and you can export charts in PNG, JPEG, SVG, or PDF. They have a nice collection of business dashboards and live demos for inspiration.

Their charts and maps work across all devices and platforms, are highly customizable, and have beautiful interactions. But with all of that, FusionCharts is slightly expensive.

DyGraphs

License: Open-source
Price: Free for all users
Main dependencies:
Web-site: http://dygraphs.com/

DyGraphs is a fast, flexible open-source JavaScript charting library. It is highly customizable, works in all major browsers (including IE8), and has an active community.

Features:

Linear regression; Synchronization across multiple graphs; Zoom capability; Highlighted regions.

DyGraphs is well suited for large and complex data sets.

D3.js

License: Open-source
Price: Free for all users
Main dependencies:
Web-site: https://d3js.org/

D3 is an open-source JavaScript library released under the BSD license. It provides a tremendous amount of charts, graphs, and other methods for data visualization. D3 gives you almost everything that you need to visually represent your data of any kind.

The website provides comprehensive documentation. There are examples provided to help with getting started and using the library.

D3 supports all modern browsers. It has been tested on browsers including Firefox, Google Chrome, Safari, Opera, IE9+, Android, and iOS.

There are two major concerns with D3.js: it has a steep learning curve and it is compatible only with modern browsers (IE 9+). Pick it up only if you have enough time to learn and adopt it.

Sigma charts

License: Open-source
Price: Free for all users
Main dependencies: No dependencies
Web-site: http://sigmajs.org

Sigma.js is built on Canvas and WebGL and has a public API, embracing a wide range of plugins contributed by the GitHub community. Sigma is fully responsive and touch interactive. It allows developers to directly add their own functions to the scripts and render nodes and edges exactly to spec.

Sigma provides a lot of different settings to make it easy to customize drawing and interaction with networks. Sigma is a rendering engine, and it’s up to you to add all the interactivity you want. The public API makes it possible to modify the data, move the camera, refresh the rendering, listen to events, etc.

It suits best for developers who need a powerful, dedicated graph drawing tool.

Morris charts

License: Open-source
Price: Free for all users
Main dependencies: jQuery
Web-site: http://morrisjs.github.io/morris.js/

Morris.js charting library is quite popular as well. It is used in many admin templates – both free and premium. The charts used in Morris focus on simplicity and effectiveness.

There are 4 types of charts in the library – line, area, bar, and donut charts.

Morris charts provide a free license. The license details are provided on the website. There is also detailed documentation for the charts.

Cytoscape

License: Open-source
Price: Free for all users
Main dependencies: No dependencies
Web-site: http://js.cytoscape.org/

Cytoscape.js is an open-source graph theory library written in JS. You can use Cytoscape.js for graph analysis and visualization.

Cytoscape.js allows you to easily display and manipulate rich, interactive graphs. Cytoscape.js includes all the gestures out-of-the-box, including pinch-to-zoom, box selection, panning, et cetera.

Cytoscape.js also has a graph analysis. The library contains many useful functions in graph theory. You can use Cytoscape.js headlessly on Node.js to do graph analysis in the terminal or on a web server.

Rickshaw by Shutterstock

License: Open-source
Price: Free for all users
Main dependencies: D3.js, jQuery, jsdom
Web-site: https://tech.shutterstock.com/rickshaw/

Rickshaw is a JavaScript toolkit for creating interactive time-series graphs. Rickshaw provides the elements you need to create interactive graphs: renderers, legends, hovers, range selectors, etc.

It’s based on d3 underneath, so graphs are drawn with standard SVG and styled with CSS. Customize everything you like with the techniques you already know.

Rickshaw is free and open-source, available under the MIT license. Developed by Shutterstock company.

CanvasJS charts

License: Paid. Free licenses to students and for Non-Commercial use.
Price: from $149 to $4999
Main dependencies:
Web-site: https://canvasjs.com/

CanvasJS is a responsive HTML5 charting library with high performance and a simple API. It supports 30 different chart types (including line, column, bar, area, spline, pie, doughnut, stacked charts, etc.), which are all well documented. All charts include interactive features like tooltips, zooming, panning, animation, etc. CanvasJS can be integrated with popular frameworks (Angular, React, and jQuery) and server-side technologies (PHP, Ruby, Python, ASP.Net, Node.JS, Java).

Koolchart

License: Paid for all users
Price: from $350 to $1280
Main dependencies:
Web-site: https://www.koolchart.com/

KoolChart is an HTML5 canvas-based JavaScript charting library. The visuals are clean and modern. The use of canvas offers better performance at the expense of being raster-based.

The API is well documented with example charts for each type. A two month trial period is available for evaluation. Licensing is required after the trial period expires.

Rawgraphs

License: Apache 2.0
Price: Free
Main dependencies: d3.js
Web-site: https://rawgraphs.io/

RAWGraphs is an open web tool to create custom vector-based visualizations on top of the d3.js library. It has been developed by DensityDesign Research Lab (Politecnico di Milano) and Calibro and sustained through corporate stewardship by ContactLab.

It works with tabular data (spreadsheets and comma-separated values) as well as with copied-and-pasted texts from other applications. Based on the SVG format, visualizations can be edited with vector graphics applications for further refinements, or directly embedded into web pages. Here’s an example gallery to explore before diving in.

Taucharts

License: Apache 2.0
Price: Free
Main dependencies: d3.js
Web-site: https://taucharts.com/

TauCharts is one of the most flexible JavaScript charting libraries out there. It is also D3 based and is a data-focused JavaScript charting library that allows for improved data visualization. The library provides a declarative interface for fast mapping of data fields to visual properties. Its architecture allows you to build facets and extend chart behavior with reusable plugins.

Talking about flexibility, TauCharts gives you easy access to their API, thus giving users the opportunity to seamlessly map and visualize data to get more amazing insights.

Anychart

License: Paid for commercial use
Price: From $49 to $799 to custom price. Free for non-commercial use
Main dependencies:
Web-site: https://www.anychart.com/

 

AnyChart is a robust, lightweight, and feature-rich JS chart library with rendering in SVG/VML. It actually gives web developers a great opportunity to create different charts that will help them conduct data analysis and make data-driven decisions.

Key Features:

More than 80 JS chart types, including basic charts, stock charts, maps, as well as Gantt and PERT charts. Many ways to set data: XML, JSON, CSV, JS API, Google Sheets, and HTML Table. Drill down into chart data. Stock technical analysis indicators and drawing tools (annotations) out-of-the-box. It can be integrated with Angular, Qlik, Oracle APEX, React, Elasticsearch, Vue.js, Android, iOS, etc.

The watermarked version is free. To get rid of the branding, as well as to use AnyChart for any commercial purpose, it’s necessary to buy a license (starts from $49).

Recharts

License: MIT
Price: Free
Main dependencies: d3.js
Web-site: http://recharts.org/en-US/

 

Recharts provides a set of modular javascript charting components and does a great job by letting you mix those components together to easily build things like a composed line and bar chart.

It is the most popular library to date. It has more than 11k stars on Github, but there is a huge number (600 to date) of open issues as well.

The documentation is quite extensive but lacks details in some parts. You can find a bunch of examples at Recharts website, which could be a good starting point for building your own charts.

What’s a bit troubling is the high number of unsolved issues on GitHub. These issues may not be critical, but creators don’t seem to drop by to answer them too often. So if you get stuck, be prepared to dig deep into the library.

Wrapping Up JavaScript Charting Libraries

With charting being something we all need to implement so often now, it’s no great surprise that there are many open-source charting libraries available for us to choose from.

All of the javascript charting libraries we mentioned above have very good browser compatibility and fallbacks available for people using legacy browsers. The libraries built upon D3 have a solid base, but personally, I find them a little bit underwhelming from an aesthetic aspect.

Javascript chart Libraries like FusionCharts, GoogleCharts, Dygraphs, or one of the D3 derivatives may work best for corporations with large data sets, or small businesses that rely heavily on data analysis. Both commercial offerings, Highcharts, and FusionCharts are mature libraries that can fit most use cases very well. Both of them have varying degrees of support for large datasets (>100k data points) and support a large variety of charts. If there is a specific type of chart you need to render, the choice might narrow down to only one of them.

If you just need something small and quick, Morris.js or Chart.js might work better for you. For graphs and networks, Cytoscape or Sigma.js is probably the way to go.

If you want to stick to a free and open-source library, use Chart.js. It is extremely simple to use for common use cases. If you need a little more control over rendering, then you could look into Chartist.

To select the best JS chart solution for your unique needs, I recommend testing your own data against a couple of the libraries listed above to ensure a perfect fit for your current and future projects.

P.S. We have prepared a table to show the popularity of libraries by downloading them through npm. We see that the most popular are d3, chart.js, and Highcharts.

 

About Flatlogic

At Flatlogic we develop admin dashboard templates and React Native templates. We are listed among the Top 20 Web Development companies from Belarus and Lithuania. During the last 6 years, we have successfully completed more than 30 big projects for small startups and large enterprises. As a team, we always have a deep desire to help our clients.

Bonus!

Honorable Mention: Victory

 

Victory by Formidable Labs caught our attention after the article originally came out. Normally, charts, templates, libraries, and other tools fall into a specific point of the beginner-pro spectrum. Beginner-friendly entries aren’t very customizable and professional tools aren’t too simple. Occasionally, however, there’s a solution that covers more ground on the spectrum, and each of those is a real treat. Victory is one such example.

Victory is customizable in just about every way an average user would ever think of. The default design is simple and concise but you can change it to something more picturesque if that’s what you’re after. And Victory comes with plenty of components and tools making it worthy of your time. Take a look:

CHARTS

VictoryBoxPlot VictoryArea VictoryAxis VictoryBar VictoryCandlestick VictoryChart VictoryErrorBar VictoryGroup VictoryLine VictoryPie VictoryPolarAxis VictoryScatter VictoryStack VictoryVoronoi VictoryHistogram

CONTAINERS

VictoryBrushContainer VictoryContainer VictoryCursorContainer VictorySelectionContainer VictoryVoronoiContainer VictoryZoomContainer createContainer Common Container Props

MORE

VictoryAccessibleGroup VictoryAnimation VictoryBrushLine VictoryClipContainer VictoryLabel VictoryLegend VictoryPortal VictoryPrimitives VictorySharedEvents VictoryTheme VictoryTooltip VictoryTransition VictoryCanvas

Creating Apps with Flatlogic Platform

We’ve covered the best JS chart libraries and how to make good use of them. Now let’s say a few words about creating complete applications within minutes and with minimal expertise in development. We created the Flatlogic platform to simplify web development to a few choices. Let’s see what they are!

#1: Name Your Project

This is the straightforward part. Pick a name you’ll associate with your project and move on to step two.

#2: Choose Tech Stack

Choose the base technologies your front-end, backend, and database will run on. In the example above, we chose React, Node.js, and PostgreSQL, respectively.

#3: Choose the Design

Choose the design of the front-end. It’s a matter of personal taste, so there are no wrong choices here.

#4: Database Schema

The schema defines how a database functions. We are to define fields, columns, data types, and relationships between all of the above. If that sounds difficult, you can pick one of the ready schemas we crafted to satisfy popular demands.

#5: Finish the App

Review the choices made so far. Choose the “Connect GIT repository” checkbox if necessary. Hit “Finish”. After that the Platform will compile for a few minutes and offer you your very own App. Enjoy!

The post Best 19 JavaScript Charts Libraries appeared first on Flatlogic Blog.

Top JavaScript Calendar Plugins

Qualities of a good javascript calendar for web applications
Top javascript calendar libraries
Recap and conclusion
About Flatlogic

About JavaScript Calendar Plugins

Calendars are an important part of our lives. In today’s world, people mostly use the web or mobile calendars. They can be found everywhere, including various software: booking apps, travel software, project management, admin panels, etc. Our company often integrates JavaScript calendar plugins into admin templates (you can look through our angular themes).

Users may need JS calendars on websites for several reasons. The user may need to pick a date from the calendar to fill up a form or provide a date while delivering any information.

Undoubtedly, this component can be called critical for business applications. Just imagine how much your business can suffer due to a badly tuned and developed calendar. Thus, this component should be given special attention and meticulousness in development.

In this article, we will look at the criteria for a good javascript calendar in web applications. Also, we will show you the best javascript calendar libraries and different frameworks for building your own solutions based on them.

Qualities of good javascript calendar plugins for web applications

We have picked the criteria for good javascript calendar plugins from our previous article on date-pickers. Obviously, we can adapt these to calendar plugins. We divided our evaluation criteria into 4 blocks.

Documentation. It is vital for whatever you’re using to be well-documented in order to learn how to build or reconstruct it. The product with no or lacking documentation does not have a right to exist.

Customization. A great library should come with options that can be updated to add or remove certain functionality. This especially applies to open-source software.

Compatibility. Who wants to visit a site with a datepicker that only works in recent versions of Chrome and Webkit browsers? Many business apps still work in legacy browsers.

User Experience. Ask yourself whether the plugin will be convenient for the needs of your user? Does it fit your product style? The looks and quality of the docs are not that important compared to how the library will actually deal with your task.

Price. And finally please keep a track of your software budget and usage.

Top JavaScript Calendar Plugins

We have included various calendar libraries based on React, Angular, Vue, Bootstrap or jQuery. Some of them are more developed, some are easier to customize. We hope this catalog will help you with your work. Let’s dive into our collection of the best JavaScript calendar plugins!

Fullcalendar.io

GitHub stars: 11.4k
Price and License: MIT
Website/Demo: https://fullcalendar.io/
Github: https://github.com/fullcalendar/fullcalendar
Type of installation: NPM, Yarn
Frameworks: React, Vue, Angular

Fullcalendar is a good choice for those who know what they want. There are no detailed step-by-step guides that describe what to do to get the goal. Only a brief Getting Started Guide and Documentation Page. Lightweight.

The library is easily customizable and has many different components. The website, demos, and documentation give the impression of a mature product, which you’re not scared to use. With this, you can plan resources and mark events. Timeline view and various themes are also there. A good asset of this library is the documentation for developing in React, Vue, and Angular.

Tui calendar

GitHub stars: 8.2k
Price and License: MIT
Website/Demo: http://ui.toast.com/tui-calendar
Github: https://github.com/nhn/tui.calendar
Type of installation: Via package managers or CDN
Frameworks: React, Vue, Angular wrappers

Tui calendar in javascript is a part of a TUI library. It is built on top or jquery with options of using React, Angular and Vue wrappers. The calendar supports various view types: daily, weekly, monthly (6 weeks, 2 weeks, 3 weeks) and efficient management of milestone and task schedules. You can change the first day of the week, customize the date and schedule information UI(including a header and a footer of grid cell).

The product has full documentation and can be installed via package managers of Content Delivery Network.

CLNDR

GitHub stars: 2.8k
Price and License: MIT
Website/Demo: http://kylestetz.github.io/CLNDR/
Github: https://github.com/kylestetz/CLNDR
Type of installation: Via package managers or CDN
Frameworks: React, Vue, Angular wrappers

CLNDR.js is a jQuery calendar plugin that, unlike most JavaScript calendar plugins, doesn’t generate markup. Instead, you provide an Underscore.js HTML template, and in return, CLNDR gives you a wealth of data to use within it. HTML templates are well-suited to this task because they allow us the flexibility to specify where we want the data to go in our markup.

CLNDR takes your template and injects some data into it. The data contains everything you need to create a calendar.

Kendo UI Scheduler

GitHub stars:
Price and License: Apache License, $999 – $2199
Website/Demo: https://demos.telerik.com/kendo-ui/scheduler/index
Github:
Type of installation: package managers
Frameworks: React, Angular, Vue, jQuery

Kendo UI is a big and advanced JavaScript framework. It contains tons of widgets and tools. Maybe it’s not a good idea to use its Scheduler Widget if you’re not interested in other components. The Kendo UI documentation is well written, and you can check out a bunch of Scheduler demos supplemented with code examples. Regarding the coding, it won’t take much time to build a basic scheduler and add some features to it. The default view is a little bit plain, but it’s easy to change that.

React big calendar

GitHub stars: 4k
Price and License: MIT
Website/Demo: http://jquense.github.io/react-big-calendar/examples/index.html
Github: https://github.com/intljusticemission/react-big-calendar
Type of installation: package managers
Frameworks: React

React big calendar is a javascript event calendar component built for React. It is made for modern browsers (read: IE10+) and uses flexbox over the classic tables-ception approach. 

React big calendar includes two options for handling the date formatting and culture localization, depending on your preference of DateTime libraries. You can use either the Moment.js or Globalize.js localizers.

Out of the box, you can include the compiled CSS files and be up and running. But, sometimes, you may want to style Big Calendar to match your application styling. For this reason, SASS files are included with Big Calendar. SASS implementation provides a file containing color and sizing variables that you can update to fit your application.

Mobiscroll responsive calendar

GitHub stars: 1.5k
Price and License: $225, $595, $1255
Website/Demo: https://mobiscroll.com
Github: https://github.com/acidb/mobiscroll
Type of installation: CLI, NPM, Yarn, Manual
Frameworks: Angular, Ionic, React, jQuery, plain JS

Mobiscroll is a library that focuses on calendaring & scheduling, date & time selection plus it ships with tools needed for building out a great user experience, like popups, form elements, different pickers for edit dialogs, and so on.

The main products:

Event calendar and scheduler with features like drag & drop, multiple resource support, CRUD operations, external drag & drop of events, workday & work week setups, and a lot of features you need to customize the experience. Their approach is not to build an event calendar that has all the bells and whistles, instead, they are adding capabilities – like event hooks, validation logic … – so that you can build the appropriate user experience that makes the most sense in your application. The calendar is customizable and ships with 3 themes: iOS, Material and Windows, light & dark variants and is fully responsive for mobile + desktop.

Date & time pickers with mobile and the desktop date and time pickers, calendars for single, multiple select, and range with start/end dates. This can be fully integrated as a stand-alone picker into existing forms or used with other Mobiscroll elements.
Other supporting components, like dialogs, dropdowns, form elements, color pickers can be seen on their demo page (with more than 250 live examples)

There are different versions available for:

Angular: Schedulerevent calendar;
React: Schedulerevent calendar;
jQuery: Schedulerevent calendar;
Plain Javascript: Schedulerevent calendar.

Other product highlights:

Localization, multilingual support;
RTL & accessibility.

Syncfusion react calendar

GitHub stars:
Price and License: $2495 – $4995 for all components
Website/Demo: https://www.syncfusion.com/react-ui-components/react-calendar
Github:
Type of installation: copy and paste script
Frameworks: Angular, Blazor, plain JS, Vue, React

The Syncfusion react calendar is a component to display the date and days of the week. It provides the month, year, and decade view options to quickly navigate to the desired date. It supports minimum dates, maximum dates, and disabled dates to restrict the date selection. The product is lightweight and easily configurable. 

You can choose across four different themes, including Material design. Apart from the standard, built-in theme, the Calendar component provides complete control over its appearance, allowing you to customize the style to suit your application.

Angular calendar

GitHub stars: 2k
Price and License: MIT
Website/Demo: https://mattlewis92.github.io/angular-calendar/#/kitchen-sink
Github: https://github.com/mattlewis92/angular-calendar
Type of installation: package manager
Frameworks: Angular

The product is a javascript calendar plugin for Angular 6.0+ that can display events on a month, week or day view. The template is highly customizable. You can build your own components instead of those not meeting your project specs.

Please note that this library is not optimized for mobile. You will need to do it yourself.

Webix JS Calendar and time selection UI controls

GitHub stars: 316
Price and License: Webix Standard is a free UI library under the GNU GPLv3 license
Website/Demo: https://webix.com/widget/date_selection/
Github: https://github.com/webix-hub/webix
Type of installation: package manager 
Frameworks: jQuery, Angular, React, Vue.js, Backbone

The product is a JS control that can be easily built into your app or web page. It’s one of the versatile JavaScript calendar plugins that can be configured according to particular requirements. 

This widget allows users to select not only days, months, and years, but also the exact time. It is easily localized and can be adapted to the local starting day of the week.  

Webix JS Calendar includes several controls. The Datepicker control facilitates choosing the required date, while the Timepicker provides different ways of time selection. Webix TimeBoard is another control for time management designed to make the process of time selection even more precise and handy. 

Bootstrap calendar

GitHub stars: 2.9k
Price and License: MIT
Website/Demo: http://bootstrap-calendar.eivissapp.com/
Github: https://github.com/Serhioromano/bootstrap-calendar
Type of installation: package manager
Frameworks: Bootstrap

Full feature calendar based on the most popular HTML framework Twitter Bootstrap. This product is reusable. It means that there is no UI in this calendar. All buttons to switch view or load events are done separately. You will end up with your own unique calendar design. It is also template based – all views including year, month, week or day are based on templates. You can easily change the looks or style, even add a new custom view. If you use this product, it will be easy to adjust and style your calendar with LESS variables file. 

It uses AJAX to feed calendar with events. You provide URL and just return by this URL JSON list of events. Language files are connected separately with i18n. You can easily translate the calendar into your language. Holidays are also displayed on the calendar according to your language.

Vcalendar

GitHub stars: 2.1k
Price and License: MIT
Website/Demo: https://vcalendar.io/
Github: https://github.com/nathanreyes/v-calendar
Type of installation: package manager
Frameworks: Vue

V-Calendar is a clean and lightweight plugin for displaying simple, attributed calendars in Vue.js. It uses attributes to decorate the calendar with various visual indicators including highlighted date regions, dots, bars, content styles and popovers for simple tooltips and even custom slot content.

Any single attribute may contain one object of each type and can be displayed for single dates, date ranges and even complex date patterns like every other Friday, the 15th of every month or the last Friday of every other month.

Dhtmlx calendar

GitHub stars:
Price and License: from $599
Website/Demo: https://dhtmlx.com/docs/products/dhtmlxCalendar/
Github:
Type of installation: package manager
Frameworks: Vue, Angular, React

This is quite a good choice if a calendar is all you want. There is an example of integration with Google maps, so you can extend the basic functionality if needed. The documentation page contains a set of guides that may be useful for beginners. The bunch of <div> containers needed to make this scheduler work may confuse you from the start, but the overall coding process is quite obvious.

The product has the following features:

Cross-browser compatibility
IE11+ support
Full control with JavaScript API
Ability to set inactive dates
Configurable first day of the week
Built-in multilingual support
12-hour and 24-hour time format
3 views: calendar, month, year

This is quite a good choice if you want to build an enterprise product. The company has good support and flexibility in prices.

Wrapping Up JavaScript Calendar Plugins

We had a look at both basic and more advanced javascript calendars. If you want a simple solution without support, but still easily customizable, then choose one of the free options. Considering more complex products, we presented paid solutions with good support quality.

About Flatlogic

To simplify web application development, we built the Flatlogic Platform. The tool allows you to create the CRUD app in minutes, you just need to choose the stack, design, and define the database model with help of an online interface and that is all. Moreover, you can preview generated code, push it to your GitHub repo and get the generated REST API docs. Try it for free!

Here is a quick guide on how to do the full-stack web app with help of Flatlogic Platform.

Step №1. Choose your projects name

Any good story starts with a title, any good React App starts with a name. So, summon all of your wit and creativity and write your project’s name into the fill-in bar in the Full Stack Flatlogic Platform.

Step №2. Select your Web App Stack

At this step, you will need to choose the frontend, backend, and database stack of your app. And, to correlate with our illustrative React App, we will choose here React for the frontend, Node.js for the back-end, and MySQL for the database.

Step №3. Choose your Web App Design

As we’ve already mentioned, design is quite important. Choose any from a number of colorful, visually pleasing, and, most importantly, extremely convenient designs Flatlogic Platform offers.

Step №4. Create your Web App Database Schema

You can create a database model with a UI editor. There are options to create custom tables, columns, and relationships between them. So, basically, you can create any type of content. Moreover, you will receive automatically generated REST API docs for your application.

Step №5. Review and Generate your Web App

In the final step, just to make sure everything is as you want it to be, you can review all of the previously made decisions and click the “Create Project” button. After a short time to generate, you will have at your fingertips a beautiful and fully functional React Node.js App. Voila! Nice and easy!

Try it for free!

Bonus: Hello Week

Source
Demo

Hello-Week is a minimalist calendar plugin we found after publishing the article. It supports multiple languages and all the functions needed for selecting dates and time stretches. And it comes with no dependencies whatsoever, so keep that in mind!

See our latest posts:

Top JavaScript Calendar Plugins
Best 19 JavaScript Charts Libraries
12 Best React Admin Templates Under $100
What is Next.js and Top Next.js Templates
Top 20+ Bootstrap Dashboard Templates to Use Absolutely Free

The post Top JavaScript Calendar Plugins appeared first on Flatlogic Blog.

361: Forks in a New Tab

If you Command (Mac) or Control (PC) click the Fork button, it will open the newly forked Pen in a new tab in your browser. That’s new behavior. Before, it would open the fork in the same tab, no matter how you click. That was unfortunate, as Cassie called out:

v smol petition for the ‘fork’ button to open in a new tab (or have the option to) on @CodePen

I’m sometimes uncertain if I’ve actually forked one of my demos or if I’m just deleting huge chunks of important stuff from the pre-forking pen.@shshaw

— Cassie Evans (@cassiecodes) March 10, 2022

Why didn’t it work like this before? Well, that’s what Shaw and I get into in this podcast. It’s a smidge complicated. The root of it is that that Fork button isn’t a hyperlink. It’s a button handled by JavaScript because of the nature of how it works (a fork might have data that only the client knows about: unsaved code changes). But Shaw found a way to make it work anyway, by essentially passing the metaKey information through all the forking process until that moment we had an opportunity to open that new tab.

Time Jumps

00:32 What was the request?

03:37 Being careful with target=”_blank”

05:14 The whole forking process

07:16 A form for example

08:41 How forks work on a pen

10:47 How did you pass the data?

13:41 It’s behaving like a link

15:29 Sponsor: Notion

17:18 A few issues

20:14 People forking instead of saving

Sponsor: Notion

Notion is an incredible organizational tool. Individuals can get a ton out of it, but I find the most benefit in making it a home base for teams. It can replace so many separate tools (documents, meeting notes, todos, kanbans, calendars, etc) that it really becomes the hub of doing work, and everything stays far more organized than disparate tools ever could.

The post 361: Forks in a New Tab appeared first on CodePen Blog.

React v18.0

React 18 is now available on npm!

In our last post, we shared step-by-step instructions for upgrading your app to React 18. In this post, we’ll give an overview of what’s new in React 18, and what it means for the future.

Our latest major version includes out-of-the-box improvements like automatic batching, new APIs like startTransition, and streaming server-side rendering with support for Suspense.

Many of the features in React 18 are built on top of our new concurrent renderer, a behind-the-scenes change that unlocks powerful new capabilities. Concurrent React is opt-in — it’s only enabled when you use a concurrent feature — but we think it will have a big impact on the way people build applications.

We’ve spent years researching and developing support for concurrency in React, and we’ve taken extra care to provide a gradual adoption path for existing users. Last summer, we formed the React 18 Working Group to gather feedback from experts in the community and ensure a smooth upgrade experience for the entire React ecosystem.

In case you missed it, we shared a lot of this vision at React Conf 2021:

In the keynote, we explain how React 18 fits into our mission to make it easy for developers to build great user experiences

Shruti Kapoor demonstrated how to use the new features in React 18

Shaundai Person gave us an overview of streaming server rendering with Suspense

Below is a full overview of what to expect in this release, starting with Concurrent Rendering.

Note for React Native users: React 18 will ship in React Native with the New React Native Architecture. For more information, see the React Conf keynote here.

What is Concurrent React?

The most important addition in React 18 is something we hope you never have to think about: concurrency. We think this is largely true for application developers, though the story may be a bit more complicated for library maintainers.

Concurrency is not a feature, per se. It’s a new behind-the-scenes mechanism that enables React to prepare multiple versions of your UI at the same time. You can think of concurrency as an implementation detail — it’s valuable because of the features that it unlocks. React uses sophisticated techniques in its internal implementation, like priority queues and multiple buffering. But you won’t see those concepts anywhere in our public APIs.

When we design APIs, we try to hide implementation details from developers. As a React developer, you focus on what you want the user experience to look like, and React handles how to deliver that experience. So we don’t expect React developers to know how concurrency works under the hood.

However, Concurrent React is more important than a typical implementation detail — it’s a foundational update to React’s core rendering model. So while it’s not super important to know how concurrency works, it may be worth knowing what it is at a high level.

A key property of Concurrent React is that rendering is interruptible. When you first upgrade to React 18, before adding any concurrent features, updates are rendered the same as in previous versions of React — in a single, uninterrupted, synchronous transaction. With synchronous rendering, once an update starts rendering, nothing can interrupt it until the user can see the result on screen.

In a concurrent render, this is not always the case. React may start rendering an update, pause in the middle, then continue later. It may even abandon an in-progress render altogether. React guarantees that the UI will appear consistent even if a render is interrupted. To do this, it waits to perform DOM mutations until the end, once the entire tree has been evaluated. With this capability, React can prepare new screens in the background without blocking the main thread. This means the UI can respond immediately to user input even if it’s in the middle of a large rendering task, creating a fluid user experience.

Another example is reusable state. Concurrent React can remove sections of the UI from the screen, then add them back later while reusing the previous state. For example, when a user tabs away from a screen and back, React should be able to restore the previous screen in the same state it was in before. In an upcoming minor, we’re planning to add a new component called <Offscreen> that implements this pattern. Similarly, you’ll be able to use Offscreen to prepare new UI in the background so that it’s ready before the user reveals it.

Concurrent rendering is a powerful new tool in React and most of our new features are built to take advantage of it, including Suspense, transitions, and streaming server rendering. But React 18 is just the beginning of what we aim to build on this new foundation.

Gradually Adopting Concurrent Features

Technically, concurrent rendering is a breaking change. Because concurrent rendering is interruptible, components behave slightly differently when it is enabled.

In our testing, we’ve upgraded thousands of components to React 18. What we’ve found is that nearly all existing components “just work” with concurrent rendering, without any changes. However, some of them may require some additional migration effort. Although the changes are usually small, you’ll still have the ability to make them at your own pace. The new rendering behavior in React 18 is only enabled in the parts of your app that use new features.

The overall upgrade strategy is to get your application running on React 18 without breaking existing code. Then you can gradually start adding concurrent features at your own pace. You can use <StrictMode> to help surface concurrency-related bugs during development. Strict Mode doesn’t affect production behavior, but during development it will log extra warnings and double-invoke functions that are expected to be idempotent. It won’t catch everything, but it’s effective at preventing the most common types of mistakes.

After you upgrade to React 18, you’ll be able to start using concurrent features immediately. For example, you can use startTransition to navigate between screens without blocking user input. Or useDeferredValue to throttle expensive re-renders.

However, long term, we expect the main way you’ll add concurrency to your app is by using a concurrent-enabled library or framework. In most cases, you won’t interact with concurrent APIs directly. For example, instead of developers calling startTransition whenever they navigate to a new screen, router libraries will automatically wrap navigations in startTransition.

It may take some time for libraries to upgrade to be concurrent compatible. We’ve provided new APIs to make it easier for libraries to take advantage of concurrent features. In the meantime, please be patient with maintainers as we work to gradually migrate the React ecosystem.

For more info, see our previous post: How to upgrade to React 18.

Suspense in Data Frameworks

In React 18, you can start using Suspense for data fetching in opinionated frameworks like Relay, Next, Hydrogen, or Remix. Ad hoc data fetching with Suspense is technically possible, but still not recommended as a general strategy.

In the future, we may expose additional primitives that could make it easier to access your data with Suspense, perhaps without the use an opinionated framework. However, Suspense works best when it’s deeply integrated into your application’s architecture: your router, your data layer, and your server rendering environment. So even long term, we expect that libraries and frameworks will play a crucial role in the React ecosystem.

As in previous versions of React, you can also use Suspense for code splitting on the client with React.lazy. But our vision for Suspense has always been about much more than loading code — the goal is to extend support for Suspense so that eventually, the same declarative Suspense fallback can handle any asynchronous operation (loading code, data, images, etc).

Server Components is Still in Development

Server Components is an upcoming feature that allows developers to build apps that span the server and client, combining the rich interactivity of client-side apps with the improved performance of traditional server rendering. Server Components is not inherently coupled to Concurrent React, but it’s designed to work best with concurrent features like Suspense and streaming server rendering.

Server Components is still experimental, but we expect to release an initial version in a minor 18.x release. In the meantime, we’re working with frameworks like Next, Hydrogen, and Remix to advance the proposal and get it ready for broad adoption.

What’s New in React 18

New Feature: Automatic Batching

Batching is when React groups multiple state updates into a single re-render for better performance. Without automatic batching, we only batched updates inside React event handlers. Updates inside of promises, setTimeout, native event handlers, or any other event were not batched in React by default. With automatic batching, these updates will be batched automatically:

// Before: only React events were batched.
setTimeout(() => {
setCount(c => c + 1);
setFlag(f => !f);
// React will render twice, once for each state update (no batching)
}, 1000);

// After: updates inside of timeouts, promises,
// native event handlers or any other event are batched.`
setTimeout(() => {
setCount(c => c + 1);
setFlag(f => !f);
// React will only re-render once at the end (that’s batching!)
}, 1000);

For more info, see this post for Automatic batching for fewer renders in React 18.

New Feature: Transitions

A transition is a new concept in React to distinguish between urgent and non-urgent updates.

Urgent updates reflect direct interaction, like typing, clicking, pressing, and so on.

Transition updates transition the UI from one view to another.

Urgent updates like typing, clicking, or pressing, need immediate response to match our intuitions about how physical objects behave. Otherwise they feel “wrong”. However, transitions are different because the user doesn’t expect to see every intermediate value on screen.

For example, when you select a filter in a dropdown, you expect the filter button itself to respond immediately when you click. However, the actual results may transition separately. A small delay would be imperceptible and often expected. And if you change the filter again before the results are done rendering, you only care to see the latest results.

Typically, for the best user experience, a single user input should result in both an urgent update and a non-urgent one. You can use startTransition API inside an input event to inform React which updates are urgent and which are “transitions”:

import {startTransition} from ‘react’;

// Urgent: Show what was typed
setInputValue(input);

// Mark any state updates inside as transitions
startTransition(() => {
// Transition: Show the results
setSearchQuery(input);
});

Updates wrapped in startTransition are handled as non-urgent and will be interrupted if more urgent updates like clicks or key presses come in. If a transition gets interrupted by the user (for example, by typing multiple characters in a row), React will throw out the stale rendering work that wasn’t finished and render only the latest update.

useTransition: a hook to start transitions, including a value to track the pending state.

startTransition: a method to start transitions when the hook cannot be used.

Transitions will opt in to concurrent rendering, which allows the update to be interrupted. If the content re-suspends, transitions also tell React to continue showing the current content while rendering the transition content in the background (see the Suspense RFC for more info).

See docs for transitions here.

New Suspense Features

Suspense lets you declaratively specify the loading state for a part of the component tree if it’s not yet ready to be displayed:

<Suspense fallback={<Spinner />}>
<Comments />
</Suspense>

Suspense makes the “UI loading state” a first-class declarative concept in the React programming model. This lets us build higher-level features on top of it.

We introduced a limited version of Suspense several years ago. However, the only supported use case was code splitting with React.lazy, and it wasn’t supported at all when rendering on the server.

In React 18, we’ve added support for Suspense on the server and expanded its capabilities using concurrent rendering features.

Suspense in React 18 works best when combined with the transition API. If you suspend during a transition, React will prevent already-visible content from being replaced by a fallback. Instead, React will delay the render until enough data has loaded to prevent a bad loading state.

For more, see the RFC for Suspense in React 18.

New Client and Server Rendering APIs

In this release we took the opportunity to redesign the APIs we expose for rendering on the client and server. These changes allow users to continue using the old APIs in React 17 mode while they upgrade to the new APIs in React 18.

React DOM Client

These new APIs are now exported from react-dom/client:

createRoot: New method to create a root to render or unmount. Use it instead of ReactDOM.render. New features in React 18 don’t work without it.

hydrateRoot: New method to hydrate a server rendered application. Use it instead of ReactDOM.hydrate in conjunction with the new React DOM Server APIs. New features in React 18 don’t work without it.

Both createRoot and hydrateRoot accept a new option called onRecoverableError in case you want to be notified when React recovers from errors during rendering or hydration for logging. By default, React will use reportError, or console.error in the older browsers.

See docs for React DOM Client here.

React DOM Server

These new APIs are now exported from react-dom/server and have full support for streaming Suspense on the server:

renderToPipeableStream: for streaming in Node environments.

renderToReadableStream: for modern edge runtime environments, such as Deno and Cloudflare workers.

The existing renderToString method keeps working but is discouraged.

See docs for React DOM Server here.

New Strict Mode Behaviors

In the future, we’d like to add a feature that allows React to add and remove sections of the UI while preserving state. For example, when a user tabs away from a screen and back, React should be able to immediately show the previous screen. To do this, React would unmount and remount trees using the same component state as before.

This feature will give React apps better performance out-of-the-box, but requires components to be resilient to effects being mounted and destroyed multiple times. Most effects will work without any changes, but some effects assume they are only mounted or destroyed once.

To help surface these issues, React 18 introduces a new development-only check to Strict Mode. This new check will automatically unmount and remount every component, whenever a component mounts for the first time, restoring the previous state on the second mount.

Before this change, React would mount the component and create the effects:

* React mounts the component.
* Layout effects are created.
* Effects are created.

With Strict Mode in React 18, React will simulate unmounting and remounting the component in development mode:

* React mounts the component.
* Layout effects are created.
* Effects are created.
* React simulates unmounting the component.
* Layout effects are destroyed.
* Effects are destroyed.
* React simulates mounting the component with the previous state.
* Layout effects are created.
* Effects are created.

See docs for ensuring resusable state here.

New Hooks

useId

useId is a new hook for generating unique IDs on both the client and server, while avoiding hydration mismatches. It is primarily useful for component libraries integrating with accessibility APIs that require unique IDs. This solves an issue that already exists in React 17 and below, but it’s even more important in React 18 because of how the new streaming server renderer delivers HTML out-of-order. See docs here.

useTransition

useTransition and startTransition let you mark some state updates as not urgent. Other state updates are considered urgent by default. React will allow urgent state updates (for example, updating a text input) to interrupt non-urgent state updates (for example, rendering a list of search results). See docs here

useDeferredValue

useDeferredValue lets you defer re-rendering a non-urgent part of the tree. It is similar to debouncing, but has a few advantages compared to it. There is no fixed time delay, so React will attempt the deferred render right after the first render is reflected on the screen. The deferred render is interruptible and doesn’t block user input. See docs here.

useSyncExternalStore

useSyncExternalStore is a new hook that allows external stores to support concurrent reads by forcing updates to the store to be synchronous. It removes the need for useEffect when implementing subscriptions to external data sources, and is recommended for any library that integrates with state external to React. See docs here.

Note

useSyncExternalStore is intended to be used by libraries, not application code.

useInsertionEffect

useInsertionEffect is a new hook that allows CSS-in-JS libraries to address performance issues of injecting styles in render. Unless you’ve already built a CSS-in-JS library we don’t expect you to ever use this. This hook will run after the DOM is mutated, but before layout effects read the new layout. This solves an issue that already exists in React 17 and below, but is even more important in React 18 because React yields to the browser during concurrent rendering, giving it a chance to recalculate layout. See docs here.

Note

useInsertionEffect is intended to be used by libraries, not application code.

Changelog

React

Add useTransition and useDeferredValue to separate urgent updates from transitions. (#10426, #10715, #15593, #15272, #15578, #15769, #17058, #18796, #19121, #19703, #19719, #19724, #20672, #20976 by @acdlite, @lunaruan, @rickhanlonii, and @sebmarkbage)
Add useId for generating unique IDs. (#17322, #18576, #22644, #22672, #21260 by @acdlite, @lunaruan, and @sebmarkbage)
Add useSyncExternalStore to help external store libraries integrate with React. (#15022, #18000, #18771, #22211, #22292, #22239, #22347, #23150 by @acdlite, @bvaughn, and @drarmstr)
Add startTransition as a version of useTransition without pending feedback. (#19696 by @rickhanlonii)
Add useInsertionEffect for CSS-in-JS libraries. (#21913 by @rickhanlonii)
Make Suspense remount layout effects when content reappears. (#19322, #19374, #19523, #20625, #21079 by @acdlite, @bvaughn, and @lunaruan)
Make <StrictMode> re-run effects to check for restorable state. (#19523 , #21418 by @bvaughn and @lunaruan)
Assume Symbols are always available. (#23348 by @sebmarkbage)
Remove object-assign polyfill. (#23351 by @sebmarkbage)
Remove unsupported unstable_changedBits API. (#20953 by @acdlite)
Allow components to render undefined. (#21869 by @rickhanlonii)
Flush useEffect resulting from discrete events like clicks synchronously. (#21150 by @acdlite)
Suspense fallback={undefined} now behaves the same as null and isn’t ignored. (#21854 by @rickhanlonii)
Consider all lazy() resolving to the same component equivalent. (#20357 by @sebmarkbage)
Don’t patch console during first render. (#22308 by @lunaruan)
Improve memory usage. (#21039 by @bgirard)
Improve messages if string coercion throws (Temporal.*, Symbol, etc.) (#22064 by @justingrant)
Use setImmediate when available over MessageChannel. (#20834 by @gaearon)
Fix context failing to propagate inside suspended trees. (#23095 by @gaearon)
Fix useReducer observing incorrect props by removing the eager bailout mechanism. (#22445 by @josephsavona)
Fix setState being ignored in Safari when appending iframes. (#23111 by @gaearon)
Fix a crash when rendering ZonedDateTime in the tree. (#20617 by @dimaqq)
Fix a crash when document is set to null in tests. (#22695 by @SimenB)
Fix onLoad not triggering when concurrent features are on. (#23316 by @gnoff)
Fix a warning when a selector returns NaN. (#23333 by @hachibeeDI)
Fix a crash when document is set to null in tests. (#22695 by @SimenB)
Fix the generated license header. (#23004 by @vitaliemiron)
Add package.json as one of the entry points. (#22954 by @Jack)
Allow suspending outside a Suspense boundary. (#23267 by @acdlite)
Log a recoverable error whenever hydration fails. (#23319 by @acdlite)

React DOM

Add createRoot and hydrateRoot. (#10239, #11225, #12117, #13732, #15502, #15532, #17035, #17165, #20669, #20748, #20888, #21072, #21417, #21652, #21687, #23207, #23385 by @acdlite, @bvaughn, @gaearon, @lunaruan, @rickhanlonii, @trueadm, and @sebmarkbage)
Add selective hydration. (#14717, #14884, #16725, #16880, #17004, #22416, #22629, #22448, #22856, #23176 by @acdlite, @gaearon, @salazarm, and @sebmarkbage)
Add aria-description to the list of known ARIA attributes. (#22142 by @mahyareb)
Add onResize event to video elements. (#21973 by @rileyjshaw)
Add imageSizes and imageSrcSet to known props. (#22550 by @eps1lon)
Allow non-string <option> children if value is provided. (#21431 by @sebmarkbage)
Fix aspectRatio style not being applied. (#21100 by @gaearon)
Warn if renderSubtreeIntoContainer is called. (#23355 by @acdlite)

React DOM Server

Add the new streaming renderer. (#14144, #20970, #21056, #21255, #21200, #21257, #21276, #22443, #22450, #23247, #24025, #24030 by @sebmarkbage)
Fix context providers in SSR when handling multiple requests. (#23171 by @frandiox)
Revert to client render on text mismatch. (#23354 by @acdlite)
Deprecate renderToNodeStream. (#23359 by @sebmarkbage)
Fix a spurious error log in the new server renderer. (#24043 by @eps1lon)
Fix a bug in the new server renderer. (#22617 by @shuding)
Ignore function and symbol values inside custom elements on the server. (#21157 by @sebmarkbage)

React DOM Test Utils

Throw when act is used in production. (#21686 by @acdlite)
Support disabling spurious act warnings with global.IS_REACT_ACT_ENVIRONMENT. (#22561 by @acdlite)
Expand act warning to cover all APIs that might schedule React work. (#22607 by @acdlite)
Make act batch updates. (#21797 by @acdlite)
Remove warning for dangling passive effects. (#22609 by @acdlite)

React Refresh

Track late-mounted roots in Fast Refresh. (#22740 by @anc95)
Add exports field to package.json. (#23087 by @otakustay)

Server Components (Experimental)

Add Server Context support. (#23244 by @salazarm)
Add lazy support. (#24068 by @gnoff)
Update webpack plugin for webpack 5 (#22739 by @michenly)
Fix a mistake in the Node loader. (#22537 by @btea)
Use globalThis instead of window for edge environments. (#22777 by @huozhi)

12+ Best React Admin Templates Under $100 [2022 Choice]

Why React

How to Pick React Templates and Which One is Better?Sofia

Inst
Sing App React
Isomorphic
Light Blue React
Easy Dev
React Material Admin Full
Acorn – React Admin Template
Skote
Flatlogic One
Hyper
Bazar Ecommerce Template

+BONUS: Build Web App on Flatlogic from the ground up

Why React

We have decided to create a list of the top React admin templates for developers that are actual and trending in 2022. Each year, we see that trends are changing, but React technology stays on top of all among JavaScript. We regularly make such listings to highlight the recent React admin dashboard that appeared on the market, for instance, you can check it here, and here.

If you need to build a powerful application and host your full-stack web application using React, Vue, Node.js, you can boost your development process with the Flatlogic platform. Starting with this CMS builder approach, you can create and host any web application reducing the time and expenses on web development.

But why do we push React forward again and again? React dashboards, and basically any admin dashboard built on React is a meaningful share representing a big part of the market.

Just check the recent statistics of React usage, US, UK, Germany and Canada take the leading positions in the world of web development according to the trends of buildwith.

Almighty React is chosen for its engaging and flexible nature. The insights of Stackoverflow and the survey of 2021 also showed that React.js library remains the most wanted and demanded technology easily surpassing jQuery among users.

However the world of JavaScript libraries is inexhaustible, and we urge you to stay tuned and keep abreast of modern web development trends keeping up with the recent tech advances.

How to Choose Which React Template is Better?

Finding an admin template that you love might take a little bit of time, but they’re easy to find on a professional marketplace, just like Flatlogic.

Frankly speaking, by and large most of these React dashboard samples are responsive, Figma ready, well documented, and have a range of UI components inside, so let’s dive into the core criteria by which we define the best admin template, UI kit, starter kit, or whatever it may be named.

Once we have already cited this ultimate list as an example of your checklist while choosing an admin template. Surely, you can make choice by the UI and the visual appearance of admin template, but the dashboard and the starter kits compounds are still the crucial take-away points to set out:

Design quality
Code quality
Installation simplicity
Documentation quality
Number of unique pages
Update policy
Quality of support
Price
Clients feedback

1. Sofia React Template

Source
Demo
GitHub
Price: free and $69 for the upgraded version

Sofia is a brand new React admin template for building any type of SAAS, CMS, IoT Dashboard, E-Commerce store. It was launched by the team of Flatlogic in 2021. Sofia is available in free version, in version with NodeJS backend and an open-source admin dashboard template built with React 17.0.1 and Bootstrap v4.6. This dashboards featuring a modern design system and lots of custom templates and components. Check the key features and pages included in the open source version of Sofia React template:

Key features:

React 17
Bootstrap 4.6 & SCSS
React Router v5
React hooks
Mobile-friendly responsive layout
Recharts and Apexcharts chart libraries
Simple login / logout
Error page
Styled Bootstrap components like buttons, badges, labels, etc
Create-react-app under the hood

2. Inst

Source
Demo
Price: $24

Inst is a super stylish React admin dashboard built with the help of popular technologies like React, TypeScript, GraphiQL, Apollo, NextJS framework and GraphQL.This web dashboard template is also among the high-selling items among Envato market, and has light and dark modes. Your digital experience will be super sleek with all its charts and chats, forms and pricing plan forms, and so on. Inside you get several authorized applications like JIRA, Slack, Figma, and Invision. Inst is a good choice for highly scalable SAAS apps.

Key features:

React
React hooks
React context api
React Next.js
Glide.js
TypeScript
Styletron component
Baseweb UI + TypeScript
GraphQL
Lerna Configuration
Apollo
Firebase CRUD

Highly responsive
SSR support

3. Sing App React

Source
Demo
GitHub
Price: $69

Sing App React is one of our advanced React templates with a rich functionality made by Flatlogic. This template has become a true bestseller since 2018, and it has rightly been praised by devs worldwide. The Sing App admin template was developed with the help of the popular Bootstrap 4, React 16 and Vue.js. It has 8 chart libraries inside, user management option, a rich ecommerce panel, static and hover sidebar, nice-looking users growth, profit and orders sections, and extremely detailed documentation. Explore all the perks for the template yourself. Use Sing App React to build online store, SAAS, CMS, financial dashboards, project management tools, etc. Sin app React package can be also checked here.

Key features:

React
Fully Responsive
2 Dashboards
E-Commerce Section
Revenue breakdown
Static & Hover Sidebar
Honed and polished UI icons
Fully Documented Codebase
Full support and updates

4. Isomorphic

Source
Demo
Price: $16

Isomorphic is a React dashboard template for SPAs, mainly aimed at CRMs and CMS systems and various SAAS products. This dashboard was originally created for hotel bookings.

Isomorphic was made with the help of React-Redux in 2017, but it is still updated and is still up-to-date thanks to the alertness of Themeforest engineers. This admin template is super native in use and helps to manage the content. The filterable tabs give your users another way to narrow the amount of options available to them.

This React template is packed with the brim with varios options inside, e.g.: ecommerce, crum board, feedback tab, YouTube search, firestore CRUD, GitHub search, chat, notes, and dozens of other elements for the most demanding devs.

Key features:

ReactJS
Redux & Redux Saga
Next.js
React router
Ant Design
Multilingual support
ES6 and CSS Components
RTL Supported
Code splitting
Invoice builder inside

5. Light Blue React

Source
Demo
GitHub / Documentation
Price: $0 for the personal license

Light Blue React is a real gem for developers and it was made with React and Bootstrap 4. The title of this React admin template may seem confusing because here we don’t mean the color of the template but the ‘lightweight’ of the dashboard. It uses server side rendering for SEO optimization and Node.js for the backend purposes. Light Blue React admin template can be used to create analytics dashboards, E-Commerce apps, CMS, SASS web apps, CRM, and many other web projects.

Key features:

React 16.5.2
Developer Oriented Dashboard
Deep background
8 Chart Libraries
Easily customizable styling & themes
Over 30 unique pages
Fully Documented Codebase

6. Matx React Dashboard Template

Source
Demo
GitHub / Documentation
Price: $39

MatX React material is a full-featured React Material Design Admin template with carefully described components, dependencies and all the staff important for web developer to easily create a web app. Developed by UI Lib, this dashboard is competing with other stylish server side rendered themes and React admin templates. The number of pages surprises: analytics dashboards, products, orders, several pricing table widgets, and dozens of other graphical UI elements are ready to use.

Key features:

Material UI
React
Redux
React Router
JWT authentication
Role based authentication
Lazy loading components
Code splitting
Vertical navigation
Horizontal navigation
Dashboard Analytics
CRUD Table
Google Map
Drag and Drop
Multilevel menu

7. Easy Dev Admin and Dashboard Template

Source
Demo
Documentation
Price: $28

One more popular React dashboard, dubbed Easy Dev, is a popular dashboard based on Redux, React, and Angular, as well as Bootstrap 4  for creating both large and small projects. Made by Themeforest, EasyDev is positioned as a modern dashboard aimed at  web and mobile apps for sport and health tracking, ecommerce stores, designing projects for providing wide analytics data, and various other web applications.

Key features:

More than 200 of UI Elements
100+ React Pages
React hooks
Redux
Redux Form
React Router 4
React-hot-loader
Free Icon Fonts
Bootstrap 4
Material-UI
React-smooth-scrollbar
Sass-lang
Constant Updates

8. React Material Admin Full

Source
Demo
GitHub
Price $69

React Material Admin Full is a fully responsive React template by Flatlogic. Among the core features of this template is React hooks. React Material admin is available in 3 color themes. From the title you could guess that the UI is composed of Google Material UI elements. Inside you will see Sketch files, and a variety of widgets, icons and essential parts of a web dashboard.

Key features:

React 16.14.0
React hooks
React context
React Router v5
Material-UI v4
CSS-in-JS styles
Mobile friendly layout
Create-react-app under the hood
Modular Architecture
Webpack build

9. Skote

Source
Demo
Documentation
Price: $23

We’re constantly checking the market of React admin dashboard templates, and checking one of the biggest markets of React admin templates, known as Envato.

Among its offers, our eyes were turned to Skote, this template is an extremely stylish admin dashboard template built on React, Bootstrap, and with the help of React Responsive Bootstrap 5.1.3, and got  7+ different layouts. You can launch your new website in any layout quickly. You can change any layout in less than a minute without changing any CSS and JS files!

10. Flatlogic One

Source and details
Demo
GitHub
Documentation
Price: $0

Flatlogic One is a dashboard template that perfectly fits any ecommerce platform, web application, SASS based interface or admin panels.  Flatlogic One has a range of various UI elements, dashboards and forms, charts, tables and maps carefully drawn by Flatlogic UX designers. Here we used JavaScript and SCSS. The template has no distracting elements that eliminates unnecessary complexity and helps to stay consistent with user intuition.

Key features:

React 16.5.2
Redux
Node.js backend
Ecommerce section
Static Sidebar
Developer Oriented Dashboard
Apexcharts.js; amCharts; Echarts,
Responsive sidebar
Datatables made by Flatlogic
Developer Oriented Dashboard
Clean design
Flatlogic Typography
Flatlogic Icons
Notifications & Icons
Google Maps

11.  Hyper React Admin & Dashboard Template

Source
Demo
Documentation
Price: $49

Hyper is a powerful admin panel with a rich number of UI elements inside. We personally love the limitless elements starting from  the basic login, signup, forgotten password and profile pages ending up with ecommerce application pages; natively built-in options of pricing and invoicing. Here you can check the landing page by coderthemes where all the options are presented fully. This is a reasonable choice for all who seek perfect digital experience when working within its app analytics.

Key Features:

Bootstrap v5.1.3
HTML5, CSS3, jQuery
React + Redux Saga library
Dex and Saga with no jQuery.
Multiple layouts
Ecommerce section with revenue
E-wallet with transaction list and money history
CRM with dashboards, projects, orders lists, etc
Material Design Icons

12. Bazar Ecommerce Template

Source
Demo
Price: $39

Bazar is one more react admin dashboard template that is a good match for sales. To be more precise, this is an ecommerce template dashboard for online retailers and tracking revenue, analyzing the behavior of customers and its geography, marketing campaigns and many more. The wide variety of layouts and styles helps to kick things off effortlessly, thanks to the React Next.js. Check your store data with your Google Analytics, social media and marketing widgets’ data to learn what drives your sales and business. The team of UI lib really went all out and made its dashboard with a perfectly clean code.

Features

React hooks
TypeScript
Material UI Core 5
Next.js 12
Lazy image loading
SSR template
Clean Code
Figma Ready
Multiple home pages
Multi-vendor pages
Formik
SEO friendly
Optimized for mobile & performance

That’s a Wrap

If you need a wider range of functionality, choose the premium versions of the same templates. All of them have high quality code, lifetime updates, and provide the user with all the necessary UI kits, components and elements that can be customized and will shave precious time off of your work.

About Flatlogic

Flatlogic is a platform for building web applications and simplifying the life of software engineers. The platform helps to create full stack applications in minutes, choosing one of the modern technologies and the design and the structure for your app yourself.

The Flatlogic team has an invincible experience and proven background in JavaScript engineering since 2013. We’re all about delivering services that enhance coders’ life, optimizing it and making it more technological. We make powerful and logical web apps for businesses around the world.

Check Out Related Articles

Top 20 Best React Website Templates for React Developers [Free and Premium]
22+ React Developer Tools to Increase Your Programming Productivity [Updated 2022]
12+ React Boilerplates & Starter Kits for Developers in 2022

The post 12+ Best React Admin Templates Under $100 [2022 Choice] appeared first on Flatlogic Blog.

360: Sarah Fossheim

I got to talk to Sarah Fossheim this week! One of the impressive things that Sarah does is near photograph-quality recreations of iconic old technology in HTML & CSS. I enjoyed the fact that neither of us quite totally knows what some of these machines even did, but appreciate their incredible aesthetics. Perhaps my favorite part of the conversation was emphasizing that this work, while almost being a relaxing hobby in the vein of knitting, still levels up one’s CSS ability. Sarah got me thinking that it’s not just CSS, but perhaps equally or more importantly HTML ability, the ability to break down sections into components and think about how smaller parts become a whole, just like any other website work.

Time Jumps

00:52 Guest introduction

01:45 Where do you find inspiration?

04:12 Calculator Pen

04:55 Roland Pen

07:02 Sponsor: Retool

08:26 Working with Text

10:35 What’s the connection to musical equipment?

13:46 Ethical Design Guide

21:36 What resources for training around accessibility are there?

24:06 Polaroid camera Pen

26:21 Have your coding skills improved?

Sponsor: Retool

Custom dashboards, admin panels, CRUD apps—build any internal tool faster in Retool. Visually design apps that interface with any database or API. Switch to code nearly anywhere to customize how your apps look and work. With Retool, you ship more apps and move your business forward—all in less time.

Thousands of teams at companies like Amazon, DoorDash, Peloton, and Brex collaborate around custom-built Retool apps to solve internal workflows. To learn more, visit retool.com.

The post 360: Sarah Fossheim appeared first on CodePen Blog.

What is MySQL

MySQL: What is it?

MySQL is an open-source relational database management system that allows you to manage relational databases based on Structured Query Language (SQL) queries. It supports multiple platforms such as Windows, Ubuntu, Linux, macOS, etc. It was developed by Swedish company MySQL AB in 1994, which was acquired in 2008 by American tech company Sun Microsystems. Afterwards, in 2010 the American giant Oracle acquired Sun Microsystems, and since then MySQL de-facto belongs to Oracle.

The database is a structured set of data, for example, a straightforward shopping list or places to store massive quantities of information throughout a business network. The relational database is a digital repository that collects data and organizes it according to a relational model, where tables consist of rows and columns and the relationships between data items follow a strict logical structure. MySQL is a simple software toolkit we can use to perform, manage, and execute queries on such a database. 

Why use MySQL?

MySQL is the most popular RDBMS, let’s look at why this is like that:

Easy-to-use. The only thing you should learn before using MySQL is a basic knowledge of SQL (Structured Query Language).

Open-source. Virtually anyone can install, modify, and use MySQL because of its incredible ease of use. The source code uses the GPL, that is, the GNU General Public License, which specifies guidelines for what you can and can’t do with this application.

High Productivity. MySQL is possibly the fastest database language, according to a multitude of standard tests.

Scalability. MySQL supports multi-threading, meaning the ability of systems to easily operate on small and large quantities of data, clusters of machines, etc. 

Security. MySQL is composed of a strong security level of data that protects confidential data from attackers. The interface is also secure because it has a versatile password system and guarantees host-based validation before accessing the database. 

Multiple data types. MySQL contains many data types, like integers, float, double, char, varchar, text, blob, date, time, DateTime, timestamp, etc.

Community. The community is very large, so if you get stuck anywhere then you can get help from the community.

Client-Server Architecture. MySQL is a client-server based architecture and accessible from anywhere through networking, i.e. each machine communicates with the server via an Internet connection. The server handles requests from the client and returns the result to the client machine. Clients can send queries to remote servers using an Internet connection, but the main requirement is keeping the server active at the time.

Who uses MySQL

MySQL is the most popular and useful database system, the largest and most important companies are probably choosing it such as:

Uber
Twitter
Slack
Airbnb
Pinterest
Amazon

Using the Flatlogic Platform you can also generate an application with a MySQL database system.

How to create your app with Flatlogic Platform

Step 1. Choosing the Tech Stack

In this step, you’re setting the name of your application and choosing the stack: Frontend, Backend, and Database.

Step 2. Choosing the Starter Template

In this step, you’re choosing the design of the web app.

Step 3. Schema Editor

In this part you will need to know which application you want to build, that is, CRM or E-commerce, also in this part you build a database schema i.e. tables and relationships between them.

If you are not familiar with database design and it is difficult for you to understand what tables are, we have prepared several ready-made example schemas of real-world apps that you can build your app upon modification:

E-commerce app;
Time tracking app;
Books store;
Chat (messaging) app;
Blog.

Like all databases in MySQL, there are such types of table relationships as relation_one, relation_many. You can enforce the relationships by defining the right foreign key constraints on the columns.

Relation (one) – one-sided relation capable of storing one or another entity, for example, Employee: [{ name: ‘John’}].
Relation (many) – two-sided relation capable of storing any number of other entities, for example, Employee: [{ name: ‘John’ }, { name: ‘Joe’ }].

Afterwards, you can deploy your application and in a few minutes, you will get a fully functional CMS application with a MySQL database system.

The post What is MySQL appeared first on Flatlogic Blog.

Data Types In JavaScript

Programming languages all have erected-in data types, but these frequently differ from one language to another. This post attempts to list the erected-in data structures available in JavaScript and what properties they have.

In this post, you will learn about the various data types available in JavaScript with the help of examples.

JavaScript provides different data types to hold different types of values. There are two types of data types in JavaScript.

Primitive data type.
Non-primitive (reference) data type.

 

Primitive data type.

The JavaScript language provides 6 primitive data types:

Undefined
Null
Number
String
Boolean
Symbol

Undefined:

A variable that has not been assigned a value has the value undefined.

var language; //variable declared but not defined.
console.log(language); // Output: undefined

Null:

A variable has been defined with a null value. It is like as undefined. It’s store nothing.

You can assign null to a variable to denote that currently, that variable does not have any value but it will have later on. A null means absence of a value.

var language = null; //It holds null value
var lang; // It holds undefined value

console.log(language == lang); // it return true, value is same of language and lang but data type different
console.log(language === lang); // it is return false, value is same of language and lang but data type different

Number:

There is only one number type. There is no specific type for integers. The number is a primitive data type used for positive or negative integer, float, binary, octal, hexadecimal, and exponential values in JavaScript

String:

A string in JavaScript is a sequence of characters. It is textual content. It can be created with the help of single or double-quotes.

var str1 = “Hello, World!”;
var str2 = ‘Hi, Welcome to JavaScript Tutorial’;

Boolean:

It is logical a entity. A variable can have two values true or false.

var isActive = true;
var isDisabled = false;

Symbol:

New in ECMAScript6. A Symbol is a unique and immutable identifier.

var x = Symbol();
var y = Symbol(10);
var z = Symbol(‘Hello’);

 

2. Non-primitive (reference) data type.

Non-primitive data types are called reference types because they refer to objects. The ‘object’ is a non-primitive data type in JavaScript. Arrays and Functions in JavaScript belong to the ‘object’ data type.

Object:

An object in JavaScript contains key-value pairs in its address. When we refer to obj1, we are actually referring to the address in memory which contains the value {a: 5, b: 6}, instead of the value {a: 5, b: 6} directly.

var obj1 = { a: 5, b: 6 };

We can change or mutate the value of obj1.

obj1[a] =7;
console.log(obj1) // will return the value {a: 7, b: 6}

Array:

With the help of an array, we can store more than one element under a single name.

// Call it with no arguments
var a = new Array();

// Call it with single numeric argument
var b = new Array(10);

// Explicitly specify two or
// more array elements
var d = new Array(1, 2, 3, “Hello”);

Find All Date Between Two Dates In JavaScript.              Different Ways To Remove An Elements From An Array In JavaScript.

The post Data Types In JavaScript appeared first on PHPFOREVER.

A pattern for dealing with #legacy code in c#

static string legacy_code(int input)
{
// some magic process
const int magicNumber = 7;

var intermediaryValue = input + magicNumber;

return “The answer is ” + intermediaryValue;
}

When dealing with a project more than a few years old, the issue of legacy code crops up time and time again. In this case, you have a function that’s called from lots of different client applications, so you can’t change it without breaking the client apps.

I’m using the code example above to keep the illustration simple, but you have to imagine that this function “legacy_code(int)”, in reality, could be hundreds of lines long, with lots of quirks and complexities. So you really don’t want to duplicate it.

Now, imagine, that as an output, I want to have just the intermediary value, not the string “The answer is …”. My client could parse the number out of the string, but that’s a horrible extra step to put on the client.

Otherwise you could create “legacy_code_internal()” that returns the int, and legacy_code() calls legacy_code_internal() and adds the string. This is the most common approach, but can end up with a rat’s nest of _internal() functions.

Here’s another approach – you can tell me what you think :

static string legacy_code(int input, Action<int> intermediary = null)
{
// some magic process
const int magicNumber = 7;

var intermediaryValue = input + magicNumber;

if (intermediary != null) intermediary(intermediaryValue);

return “The answer is ” + intermediaryValue;
}

Here, we can pass an optional function into the legacy_code function, that if present, will return the intermediaryValue as an int, without interfering with how the code is called by existing clients.

A new client looking to use the new functionality could call;

int intermediaryValue = 0;
var answer = legacy_code(4, i => intermediaryValue = i);
Console.WriteLine(answer);
Console.WriteLine(intermediaryValue);

This approach could return more than one object, but this could get very messy.

Building a gRPC Client in .NET

Introduction

In this article, we will take a look at how to create a simple gRPC client with .NET and communicate with a server. This is the final post of the blog series where we talk about building gRPC services.

Motivation

This is the second part of an articles series on gRPC. If you want to jump ahead, please feel free to do so. The links are down below.

Introduction to gRPC
Building a gRPC server with Go
Building a gRPC client with .NET
Building a gRPC client with Go

Building a gRPC client with .NET (You are here)

Please note that this is intended for anyone who’s interested in getting started with gRPC. If you’re not, please feel free to skip this article.

Plan

The plan for this article is as follows.

Scaffold a .NET console project.
Implementing the gRPC client.
Communicating with the server.

In a nutshell, we will be generating the client for the server we built in our previous post.


💡  As always, all the code samples documentation can be found at: https://github.com/sahansera/dotnet-grpc

Prerequisites

.NET 6 SDK
Visual Studio Code or IDE of your choice
gRPC compiler

Please note that I’m using some of the commands that are macOS specific. Please follow this link to set it up if you are on a different OS.

To install Protobuf compiler:

brew install protobuf

Project Structure

We can use .NET’s tooling to generate a sample gRPC project. Run the following command at the root of your workspace. Remember how we used dotnet new grpc command to scaffold the server project? For this one though, it can simply be a console app.

dotnet new console -o BookshopClient

Your project structure should look like this.


You must be wondering if this is a console app how does it know how to generate the client stubs? Well, it doesn’t. You have to add the following packages to the project first.

dotnet add BookshopClient.csproj package Grpc.Net.Client
dotnet add BookshopClient.csproj package Google.Protobuf
dotnet add BookshopClient.csproj package Grpc.Tools

Once everything’s installed, we can proceed with the rest of the steps.

Generating the client stubs

We will be using the same Protobuf files that we generated in our previous step. If you haven’t seen that already head over to my previous post.

Open up the BookshopClient.csproj file you need to add the following lines:


<ItemGroup>
<Protobuf Include=../proto/bookshop.proto GrpcServices=Client />
</ItemGroup>

As you can see we will be reusing our Bookshop.proto file. in this example too. One thing to note here is that we have updated the GrpcServices attribute to be Client.

Implementing the gRPC client

Let’s update the Program.cs file to connect to and get the response from the server.

using System.Threading.Tasks;
using Grpc.Net.Client;
using Bookshop;

// The port number must match the port of the gRPC server.
using var channel = GrpcChannel.ForAddress(“http://localhost:5000”);
var client = new Inventory.InventoryClient(channel);
var reply = await client.GetBookListAsync(new GetBookListRequest { });

Console.WriteLine(“Greeting: “ + reply.Books);
Console.WriteLine(“Press any key to exit…”);
Console.ReadKey();

This is based on the example given on the Microsoft docs site btw. What I really like about the above code is how easy it is to read. So here’s what happens.


We first create a gRPC channel with GrpcChannel.ForAddress to the server by giving its URI and port. A client can reuse the same channel object to communicate with a gRPC server. This is an expensive operation compared to invoking a gRPC method on the server. You can also pass in a GrpcChannelOptions object as the second parameter to define client options. Here’s a list for that.
Then we use the auto-generated method Inventory.InventoryClient by leveraging the channel we created above. One thing to note here is that, if your server has multiple services, you can still use the same channel object for all of those.
We call the GetBookListAsync on our server. By the way, this is a Unary call, we will go through other client-server communication mechanisms in a separate post.
Our GetBookList method gets called on the server and returns the list of books.

Now that we know how the requests work, let’s see this in action.

Communicating with the server

Let’s spin up the server that we built in my previous post first. This will be up and running at port 5000.

dotnet run –project BookshopServer/BookshopServer.csproj


For the client-side, we invoke a similar command.

dotnet run –project BookshopClient/BookshopClient.csproj

And in the terminal, we will get the following outputs.


Nice! as you can see it’s not that hard to get everything working 🎉 One thing to note is that we left out the details about TLS and different ways to communicate with the server (i.e. Unary, streaming etc.). I will cover such topics in-depth in the future.

Conclusion

In this article, we looked at how to reuse our Protobuf files to create a client to interact with the server we created in the previous post.

I hope this article series cleared up a lot of confusion that you had about gRPC. Please feel free to share your questions, thoughts, or feedback in the comments section below. Until next time 👋

References

https://docs.microsoft.com/en-us/aspnet/core/tutorials/grpc/grpc-start?view=aspnetcore-6.0&tabs=visual-studio-code