đ· Cover image: Joseph Gonzalez
I watched this talkâ» by Chris Biscardi at ESNext Conf, where he presented his new JAMstack meta framework, Toast, and the reasoning behind its creation.
â») The live video was taken off. Presumably the talks will be posted separately on the ESNext Conf YouTube channel later.
Toast is described as an âESModules-first JAMStack and Serverless meta-frameworkâ. Itâs currently in alpha (0.2.7 at the time of writing), and as the readme saysâŠ
Current stability status: somewhere between a yeet and a yolo
The best place to stack your jam
Toast
The best place to stack your JAM.
Current stability status: somewhere between a yeet and a yolo
About Toast
Toast is a modern, ESModules-first, site compiler. It avoids bundlers completely
by default (although you can integrate bundlers if you need to).
You can read about the high level vision or the current
goals of the project.
What types of sites is Toast useful for?
We don't know yet. It's mostly being used for blogs currently.
What browsers does Toast support?
Notably the use of browser-native features like ESModules in the default
client-side JavaScript
means no IE 11 support.
Getting Started
The following command will bootstrap a new toast app for you.
Thanks
What makes Toast stand out from existing popular JAMstack frameworks is its emphasis on modern JavaScript native browser functionalities. It is unbundled by defaultâalthough you can optionally add oneâwhich results in a simple, performant build process. In a way, itâs like if Gatsby were built without webpack and GraphQLâ»â».
â»â») I think Chris said something to this effect in the talk. The video link has been taken off by the time Iâm writing this so I could not cross-check.
Check out the Vision page in their documentation to learn more about Toastâs underlying philosophy and direction.
How does it work?
Thatâs a literal question, not a lead into a descriptive paragraph đŹ.
As per the talk slide, Toast uses Snowpack/Rollup. We can set up the Snowpack configuration in our package.json
(see sample site code).
Beyond that, I was not able to find out:
- where the Snowpack/Rollup config is defined in the source code
- where and how to extend or override the configuration (or if itâs possible at all)
It could be somewhere in the accompanying `breadbox` package, but I did not have the time/energy/knowledge to dwelve into it.
EDIT: Chris confirmed that the configuration is indeed in the breadbox package.
For now I'll leave it to you, readers, to check it out. đŹđ In this post Iâm only going to discuss basic usage without custom or advanced configuration.
Installation
My experience creating a new Toast site from the starter was a breeze.
You can create a new Toast site by doing any one of these:
- starter site, new-toast-site
- Use the âDeploy to Netlifyâ button (forks the starter site to our Github account, create a new Netlify site, and deploys there)
- Clone the repo to your local directory
-
CLI command yarn create toast Not working now
Run yarn
to install dependencies, and yarn build && npx serve public
to serve.
Toast Example Site
This repo is an implementation of the experimental Toast package. It will be updated as Toast is updated with new features.
Try it out:
git clone git@github.com:ChristopherBiscardi/new-toast-site.git
cd new-toast-site
yarn
yarn build
npx serve public
Info
This site includes
- First-class MDX support
- Server-side rendered syntax highlighting
- Codeblock highlighting
- MDXProvider usage
- babel-plugin-preval examples
- static/ folder usage
- src/pages for .js files
- When selecting text on the page, a tweetable selection will pop up.
- Styling is done with emotion although this can be replaced with Tailwind or whatever you prefer
- Preact
More Examples
Existing Toast sites can be found in the wild at the following locations. Feel free to check out the network traffic to see what an ESM-first approach looks like in practice.
Feedback
Please file issues. ToastâŠ
Developing
This is where I came across the first âoopsâ. Toast has no live/development server, ie. no such thing as yarn toast develop
or yarn toast start
.
If you want to develop with live reloading capability (to see the changes as you code), you have to do it in a separate environment. I would develop the components in Storybook.
Fetching data
Toast supports MDX out of the box. The starter site comes with customizable prism code highlighting. Data fetching/processing and page creation happens in https://github.com/ChristopherBiscardi/new-toast-site/blob/toaster/toast.js.
toast.js
gets posts data from fetch-mdx-post-files
(the starter site has sample posts in content/posts
directory), which we can modify if we want to. I have not tried it, but we should be able to fetch data from external API as data source as well.
Styling etc
The starter site comes with Emotion for CSS and React Helmet for SEO/Metadata. These packages are regular dependencies, so you can replace them with any libraries you want.
The starter site also comes with:
- (Client-side) filtering by tags and keyword
- âTweet thisâ on selecting text
- Progress bar indicating reading (= page scroll) progress
Deploying
Itâs already built and ready to deploy âš. You should be able to deploy the public
directory anywhere you can host a static site, such as Netlify, Vercel, and Github Pages.
I used the Netlify deploy button, so my site repository is already connected to Netlify, which automatically runs a build anytime I push to master
branch.
Ecosystem
As a new framework in alpha essentially run by one person, (understandably) there are no plugins, integrations, or resources like templates and tutorials.
Chris, the creator, is active on Twitter and his Discord channel Party Corgi. If you have questions or discussion that seem out of place for Toast repo issues, you can reach him there.
My impressions
I havenât got a lot of time to play with Toast (but just enough to make me crave actual toast). Iâm personally enjoying it so far and can see myself adding it to my tool belt.
What I liked:
- Less data sent to user (good if you are performance budget-conscious)
- Uses Preact instead of React out of the box
- Faster builds
- (Arguably) more simple, less opinionated than larger React JAMStack frameworks
- Less tooling means less possibility of cryptic webpack errors coming out of nowhere
Deal-breakers: (you may not be happy with Toast if you require these)
- Established ecosystem (plugins, tutorials, etc)
- IE11 support â»â»â»
- Advanced client-side routing â»â»â»
â»â»â») Yes, itâs possible to install polyfill and custom libraries if youâre willing to add hours of extra work.
At the end of the day, Iâm glad Toast makes the ecosystem even richer by approaching it from a different perspective from larger React-based JAMStack meta frameworks. Add to that other meta frameworks based on Vue, Svelte, and non-framework JavaScript (11ty), developers are spoiled for choice when it comes to creating with the JAMStack.