Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Every app on this page is built from the three layers described in HTML, CSS and JavaScript. Each library adds to one or more of these layers.

LayerWhat libraries addExamples
JavaScriptdata, charts and maps drawn into an HTML elementDuckDB-WASM, Observable Plot, D3, MapLibre, deck.gl
CSScolors, fonts and layouts that adapt to the screenPico CSS, Bootstrap, Tailwind CSS
HTMLnew elements such as tabs, drawers and dialogs, defined with JavaScriptWeb Awesome
All threecomponents written together and compiled into plain filesSvelte, React, Vue, Observable Framework

The starter app uses plain HTML and CSS and two JavaScript libraries: DuckDB-WASM reads the data and Observable Plot draws the chart. This page tours the major libraries for each layer through apps that people actually use, grouped by the themes of Modules 1 to 3. Use it to find an app worth imitating, and then find out how that app was built.

Reading an app

Every client-side app can be read in the same way. Open the app, then open the browser’s developer tools.

Ask your coding agent to explain what it finds, the same way you asked it to explain an unfamiliar ibis expression in Module 1.

Charts

Chart libraries are JavaScript. Each one takes data and draws a chart into an element on the page, usually as SVG, which is itself a kind of HTML that CSS can style. Observable Plot is one of several grammar-of-graphics libraries for the browser. Vega-Lite is the library underneath Python’s Altair, so a chart you write in Altair in a notebook can be exported as a Vega-Lite spec and embedded in a web page. D3 is the lower-level library that Plot is built on, and most custom newsroom graphics use it directly. Apache ECharts and Plotly.js are chart libraries with many ready-made chart types and built-in zooming and tooltips.

These apps build on the climate data from Module 1.

Maps

Map libraries are JavaScript, together with a small CSS file for the zoom buttons and popups. The map fills one <div> on the page and draws with the computer’s graphics card. In Module 2 we used MapLibre through leafmap, which writes this JavaScript for us. Writing MapLibre in JavaScript directly opens up much more of it. The MapLibre examples include a globe, 3D terrain, and a cloud-optimized GeoTIFF read directly in the browser with the maplibre-cog-protocol plugin, so the COGs from Module 2 can be shown on a static site with no tile server. PMTiles does the same for vector data: one file holds all the tiles for a map, and the browser requests only the tiles it needs. You can drop a PMTiles file on the PMTiles viewer to inspect it.

Other map libraries are worth knowing. deck.gl draws millions of points, arcs and hexagons on the GPU, and can be layered on a MapLibre map. kepler.gl is a complete map app built on deck.gl, into which you can drop a CSV or GeoJSON file. Leaflet is older and simpler and does not use WebGL, and OpenLayers has the widest support for map projections and GIS formats.

These apps build on the environmental justice theme of Module 2.

Linked views and SQL in the browser

When a reader selects a range in one chart and every other chart filters to match, the charts are linked. Mosaic links Observable Plot charts through DuckDB-WASM, so each selection becomes a SQL query. Its ten million flights and Gaia star catalog examples filter millions of rows as fast as the reader can drag. The DuckDB shell runs DuckDB-WASM in a browser tab, which is a quick way to test a query on a remote Parquet file before you put it in your app.

Observable Framework builds a whole data site from markdown pages with code in them, and adds a sidebar, a grid of cards and dark mode. Its examples include a dashboard of the US electricity grid and a map of US dams.

Models and simulations

A model explorer runs a calculation in the browser every time a slider moves. JavaScript is fast enough for most models from an ecology course, and these apps show how far the idea goes.

The tools from Module 3 can also run in the browser, with one important limit: any API key in a client-side app is public. An app can call the NRP language model only through a server that holds the key. A static app can still search text by meaning if the paragraph embeddings are computed ahead of time and saved to a file, and the reader’s query is embedded in the browser by Transformers.js.

Streamlit and Shiny galleries

The Streamlit gallery, the Shiny for Python gallery and the Shiny for R gallery collect hundreds of data apps, most with a link to their source code. These apps run on a server. Free hosted apps are put to sleep when nobody uses them, so the first visit can take a minute while the server wakes up, which is the cost of server-side apps described in the Module 4 introduction. Many of them translate directly into a client-side app. The data file becomes a static CSV or Parquet file read by DuckDB-WASM, each widget becomes an HTML input, and each chart becomes an Observable Plot or Vega-Lite chart. These apps would translate well.

The Shiny for Python templates are worth browsing for layout alone. The restaurant tips dashboard shows a common arrangement of summary numbers in a row across the top, filters in a sidebar, and cards that each hold one chart or table.

Layout and components

The starter app uses plain HTML and a short stylesheet of its own. Layout and component libraries replace that stylesheet, or add new HTML elements, so that menus, tabs, dialogs and grids look consistent and rearrange themselves on a phone. They differ in which layer they work in.

Larger apps use a JavaScript framework. A framework lets you write each part of the interface as a component that holds its own HTML, CSS and JavaScript together, and it updates the page whenever the app’s state changes. A build step then compiles the components into ordinary HTML, CSS and JavaScript files. Svelte is common in newsrooms, and LayerCake is a chart library for it. React powers the Our World in Data Grapher and the Overture explorer above, and Vue powers STAC Browser.

Each of these libraries is a dependency that you must pin and test. Svelte, React, Tailwind and Observable Framework also need a build step, which turns your source files into the files that GitHub Pages serves, so the deploy workflow in the template would need a new step to run it. Libraries such as Pico, Web Awesome and MapLibre can be loaded from a pinned URL with no build step at all. Choose the smallest set of tools that does what your readers need.

The Shiny layouts page is a useful catalog of the standard arrangements, such as a navigation bar, a sidebar, tabs and cards, each with a picture. The same arrangements can be built with any of the libraries above.

A few habits make an app work on a phone whatever library you choose:

Scrolling stories

Some apps are read from top to bottom, with the chart or map changing as the reader scrolls. Scrollama is a small library that tells your code which paragraph is on screen. Bloomberg’s What’s really warming the world? adds one possible cause of warming at a time, from the sun to volcanoes to greenhouse gases, and compares each one with the observed temperature record.