Image for post
Image for post
Happy cows produce good buttermilk, and good ingredients make for great apps!

Introducing Buttermilk ⚪️

Beautifully simple routing for React projects.

Evan Jacobs
Mar 27, 2018 · 3 min read


path: String | RegExp | Function,
redirect: String?,
render: Function?,
path: '/foo',
render: () => import('./SomePage').then(mdl => mdl.default),

Using the right route


<Link>ing up your views

import { Link } from 'buttermilk';<Link href="/one/of/your/routes">
Some text
import { Link } from 'buttermilk';<Link as="button" href="/one/of/your/routes">
Some text
import { Link } from 'buttermilk';
import styled from 'styled-components';
const Anchor = styled.a`
color: tomato;
<Link as={Anchor} href="/one/of/your/routes">
Some text

Switching routes programmatically

import { route } from 'buttermilk';// acts like push / pushState
import { route } from 'buttermilk';// acts like replace / replaceState
route('/foo', false);

Consuming the current route state

// routingProps.location  (the parsed current URL in window.location.* form)
// routingProps.params (any extracted dynamic params from the URL)
// routingProps.route (the current route)
{routingProps => {
return /* some JSX */;

Putting it all together

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store