Blitz.js – Fullstack Toolkit for Next.js
blitzjs.com
blitzjs.com
[Feb 2020]: First announced. [Apr 2020]: First alpha release. [Feb 2021]: First beta release. [Dec 2021]: Decided to do major pivot.
Today the Blitz.js 2.0 pivot to a modular Next.js toolkit reached Beta status [1]
Previously Blitz abstracted Next.js, but Blitz 2.0 is now a modular toolkit that plugs into any new or existing Next.js app. Blitz picks up where Next.js leaves off, providing libraries and conventions for shipping and scaling small to large apps.
When I first created Blitz, my aim was to have an all-in-one fullstack framework for Javascript like Ruby on Rails. But that proved to be too difficult. I've decided that achieving an all-in-one framework for JS like Rails is too difficult unless you have a ton of funding and don't have to make meaningful money.
The difference with JS is that client-side frameworks like React have an incredible amount of complexity. Trying to manage all of that and all the other fullstack framework stuff like API layers, auth, file uploads, etc is too large of scope.
So now Blitz is no longer trying to do it all and is focusing on all the non-frontend functionality you need to ship web apps.
Going forward, we want to be the most trusted technical resource for rapidly building and scaling full-stack TypeScript apps.
[1] https://github.com/blitz-js/blitz/releases/tag/v2.0.0-beta.1
There's some obvious risk in your business model but I'm 100% rooting for you.
We're planning to switch pricing to tiers. Psychologically 30% sounds like a lot, although the end price is quite low. For example we have a site with close to 10 million requests per month with heavy server compute. Their cost is about AWS $300/mo and Flightcontrol $90/month.
Not that it’s going to happen. But there’s a plethora of obvious risks.
BTW - to the author of FC, this is not directed against you. I hope you do well. And I’m really excited for the revised vision - I actually joined the Discord today.
My personal project stack is Vercel + NextJS + Blitz + Supabase. I can choose to use Blitz’s auth if I need rich OAuth providers, or Supabase’s if I’m building something super simple. I think Prisma (which Blitz bundles as the database access layer) is more productive in the domain of single weekend dev than Rails/ActiveRecord or Django’s ORM.
Here’s the task list:
1. Create Supabase project (2 clicks)
2. Create project with Blitz generator (1 command)
3. Create git repo on GitHub & push (2 clicks)
4. Create Vercel deploy for git repo (3 clicks)
I don’t think there’s a stack out there that can take you from zero to a full stack richly interactive app with CDN caching, auth, database, and live refresh as quickly. If you only want server rendering, Rails + Supabase + Render might be close, but if you’re familiar with Typescript it really is a dream.
I really recommend checking it out if you’re into Typescript.
I deploy on AWS AppRunner or Google CloudRun which takes care of the HTTPS/TLS and domain bits.
Some notes:
- The problems with tRPC "at scale" are fixable by using project references, but not going to downplay that it's an annoying refactor to do (https://github.com/microsoft/TypeScript-Handbook/blob/master...)
- All of the problems with trpc are inherent of any ts thing that is heavilily reliant on inference (hence also blitz) (https://github.com/microsoft/TypeScript/wiki/Performance#wri...)
- The ts perf things that set trpc apart and make you feel it earlier in tRPC than blitz are largely resolved by the new major of trpc that is currently in a stable alpha (stable in terms of no known bugs, but API might change)
However, this reminds me of the early Rails (or even Rails 4.0) demos that I saw where they build a blog in 5 minutes.
Here is the thing: The fastest way to get a skeletal app running -- even if it is written in C -- is to
> git clone already_written_archetype.lang
And then you can modify it.
So you can put that archetype into the framework. So I always wonder if the right example is not build a blog or to-do-list or twitter clone. The right example might be:
take a blog and change it into a twitter clone
Because you can always download the archetype if you need to but the framework should demonstrate how nimble it is. (Again, I don't claim Blitz is not nimble and I would have to play with it to know.)
Future of Blitz - https://news.ycombinator.com/item?id=30896931 - April 2022 (31 comments)
Blitz: A Fullstack React Framework, Built on Next.js - https://news.ycombinator.com/item?id=27411975 - June 2021 (35 comments)
Blitz.js Now in Beta (Batteries Included Framework Built on Next.js) - https://news.ycombinator.com/item?id=26166716 - Feb 2021 (78 comments)
Want a better React stack? Try React + tRPC + Express + Prisma. Each component can be easily swapped out and understood independently (sorry Next.js / Remix), all routing is explicit (sorry Next.js / Remix), development startup time is fast (sorry Next.js), and you still get e2e type safety + minimal boilerplate. I like to call this stack the "NF" stack: "No Framework".
The fanboys will complain. "What about SSR?", they will say. Well, here's the solution: quit fretting about SSR. Your signed-in customers will gladly take 0.05 seconds extra render time for the extra features your devs will be able to deliver after you ditch your complicated SSR framework. Want to do SEO? Make a WordPress site and "SSR" it with Simply Static[0]. Your site will achieve the theoretical minimum Time To First Whatever, your marketing team will be free to actually do their job rather than spending 2/3 of their time trying to get devs to update the landing page, and your devs can move on to something more useful (like creating useful features. Isn't that supposed to be the goal?)
/rant
[0] https://wordpress.org/plugins/simply-static/
(edited to remove some unnecessary negativity)
I'm personally conflicted: I see the upside of Blitz for sure (and find it impressive) but I also have been ultra-burned by frameworks & certainly would never give up Vite.
As far as I can tell the implementations between TRPC and BlitzRPC are very different. One basically (paraphrasing their own words) abuses Typescript & requires some maintenance, where BlitzRPC appears to be a "Svelte-like" everything is a compiler approach.
There's a real scaling issue with tRPC (they say something like unsuitable for large projects IIRC).
Would you mind to elaborate?
It's like back when everybody was going through the "I want to use Sinatra rather than Rails" phase and what happened was a million different half-baked reimplementations of 20% of Rails that were different on each project for no significant benefit.
Another thought: You are on HN, so you probably prefer Unix to Windows. Why do you think that is?
(I'm on the Vercel/Next.js team) Could you share specifically what configuration you found obsolete?
> I really wish frontend react stacks would stabilize
Did you have trouble upgrading versions? Open to feedback. We frequently hear folks who upgrade from Next.js 8 to 12 with minimal changes, for example.
I could be completely wrong, but it feels like building on so many abstractions, one tends to lose insight into the underlying stack and you eventually enter a diminishing returns territory.
There's 2 problems though: 1. Does the Blitz RPC thing work the same way as TRPC? If so then it will suffer the same slowdown at scale and basically have to be removed once a project reaches a certain size?
2. Having got used to Vite I just cannot go back to Webpack (which IIRC Next still wraps).
tRPC as I understand it basically serves definition files to the client using a clever misuse of Typescript - but over time that means Typescript has to conditionally evaluate every type in your app to find the correct one. Or something like that.
My understanding of BlitzRPC from their documentation is it's more Svelte-like with the "everything is a magic compiler" philosophy. This may come with issues but it sounds pretty nice.
Blitz RPC has 1 minimal magic step, which is a webpack step to replace the resolver imports in client code with a fetch function and to add resolvers to the server-side API endpoint.
And we'll be adding an API that lets you use Blitz RPC without webpack or any compile step.
Depends what you mean by "same way". Yes in that both provide fully typesafe client-server communication. No in that the Blitz implementation is a tiny fraction of the size and does not have any Typescript-related performance slowdown at scale like TRPC.
The Blitz RPC tech itself will scale forever. However as a company scales it'll probably face another problem which is API contracts between internal teams. When you hit that, you may want to adopt GraphQL.
> 2. Having got used to Vite I just cannot go back to Webpack (which IIRC Next still wraps).
Yep, I want Next.js to get off webpack too
Since you say Blitz is no longer tied to Next - does that mean it can be used with Vite? Again I doubt I am alone in thinking this would be huge.
I've said it in other comments but to repeat - I think this is super interesting.
Honestly I can't decide whether this is a framework or a feature. But it's definitely interesting.
Yes, it's coming.
> does that mean it can be used with Vite?
Yes, but we do have a bit more work to clean up our internal package dependencies and APIs so that this works.
It makes me feel like we're on the verge of having a really great tool in this space. (Or maybe even two.)
However, the downside of custom session managers is that other services might not be able to read/write the created session. For example, I'm currently to get off of Express and onto Fastify. Unfortunately, @fastify/session isn't perfectly compatible with express-session (although I'm working on it). I would have a similar issue if I introduced Next.js + Blitz... Sometimes, I wish there was a shared protocol for sessions between languages/libraries!
But... wouldn't a Terraform module accomplish something similar? Our own stack is something like Codepipeline + Fargate + ALB + Cloudwatch + Cloudfront and we basically just forked https://github.com/cloudposse/terraform-aws-ecs-web-app
All in all, buy vs. build is a tough question but generally SaaS wins once it is a viable option for real-world teams. In developer experience, we are still in the early innings on convincing folks it's worth it not to reinvent the wheel in-house.
Would love anyone interested to check out our free trial and feel free to ping hn@withcoherence.com with feedback or questions!
1. Next.js is Very Minimal
That's Next's best feature. I wouldn't want to replace that.
Blitz does not replace anything of Next.js. Rather, it compliments it's minimalism.
To build a full app, you need to add a lot of things on top of Next.js. Blitz provides some of those libraries.
(disclaimer: I’m the founder)
It seems to be authentication and a graphql alternative for web devs? Why not just say that and have a side by side comparison of graphql and this on the front page? Words like 'scaling world wide applications' strike me as empty.
Here's a side-by-side comparison to GraphQL from some time back: https://twitter.com/flybayer/status/1256957956270120960
If this is a better GraphQL, it better say 'Better GraphQL' and have a side by side comparison, showing how it is obviously so much better.
Messaging is not hard, having a superior product is hard.
(Blitz wraps NextJS wraps React)
Again I repeat, that is what Blitz used to be. Blitz no longer wraps Next.js. It's no longer a framework.
The goal for beta was to reach Next.js production feature parity with legacy Blitz. Now we can turn to cleaning it up for other uses.
It feels like it stands out even more because of mutation handlers, which on the Remix side are generally set up as "just" form posts that update after a success.
Just use the language people!
Writing 3 LOC instead of 1 call to an external package is OKAY.
If you properly build a large codebase using patterns like Clean Architecture, then tools like Next.js or Blitz should be fully isolated away from your app logic.
If you need auth in Next.js, your options are Blitz Auth or Next Auth. Try both and see which you like best.
If you need type safe client/server communication, Blitz RPC is one of the options.
Neither of these dictate absolute control over your code as your comment implies.
Should they? For small startups it might be better to skip paying the cost of such abstraction and just marry with a mature technology.