Convert Figma logo to code with AI

blitz-js logoblitz

⚡️ The Missing Fullstack Toolkit for Next.js

13,599
792
13,599
73

Top Related Projects

124,777

The React Framework

29,083

Build Better Websites. Create modern, resilient user experiences with web fundamentals.

17,089

The App Framework for Startups

18,419

web development, streamlined

54,014

The Intuitive Vue Framework.

55,199

The best React-based framework with performance, scalability and security built in.

Quick Overview

Blitz.js is a full-stack React framework built on Next.js, designed to accelerate web application development. It provides a seamless, zero-API data layer and includes everything you need to build scalable, production-ready applications with React.

Pros

  • Zero-API data layer, eliminating the need for manual API creation and management
  • Built-in authentication and authorization system
  • Automatic code splitting and optimized performance
  • Strong conventions and best practices for scalable application architecture

Cons

  • Steeper learning curve compared to plain React or Next.js
  • Less flexibility in some areas due to opinionated structure
  • Smaller community and ecosystem compared to more established frameworks
  • May be overkill for simple projects or static websites

Code Examples

  1. Defining a model and query:
// app/products/queries/getProduct.ts
import { resolver } from "blitz"
import db from "db"

export default resolver.pipe(
  resolver.zod(z.object({ id: z.number() })),
  async ({ id }) => {
    const product = await db.product.findFirst({ where: { id } })
    return product
  }
)
  1. Using the query in a React component:
// app/products/pages/[id].tsx
import { useQuery, useParam } from "blitz"
import getProduct from "app/products/queries/getProduct"

export default function Product() {
  const id = useParam("id", "number")
  const [product] = useQuery(getProduct, { id })

  return (
    <div>
      <h1>{product.name}</h1>
      <p>{product.description}</p>
    </div>
  )
}
  1. Defining and using a mutation:
// app/products/mutations/createProduct.ts
import { resolver } from "blitz"
import db from "db"

export default resolver.pipe(
  resolver.zod(z.object({ name: z.string(), price: z.number() })),
  async (input) => {
    const product = await db.product.create({ data: input })
    return product
  }
)

// Using the mutation in a component
import { useMutation } from "blitz"
import createProduct from "app/products/mutations/createProduct"

export default function CreateProductForm() {
  const [createProductMutation] = useMutation(createProduct)

  return (
    <form
      onSubmit={async (event) => {
        event.preventDefault()
        const product = await createProductMutation({ name: "New Product", price: 9.99 })
        console.log(product)
      }}
    >
      {/* Form fields */}
    </form>
  )
}

Getting Started

To create a new Blitz.js project, run the following commands:

npm install -g blitz
blitz new my-blitz-app
cd my-blitz-app
blitz dev

This will create a new Blitz.js project and start the development server. You can then open your browser and navigate to http://localhost:3000 to see your new Blitz.js application running.

Competitor Comparisons

124,777

The React Framework

Pros of Next.js

  • Larger community and ecosystem, with more resources and third-party integrations
  • Better performance optimization out of the box, including automatic code splitting
  • More flexible, allowing for both static site generation and server-side rendering

Cons of Next.js

  • Requires more configuration and boilerplate code for full-stack applications
  • Less opinionated, which can lead to inconsistencies in project structure
  • Lacks built-in authentication and database integration

Code Comparison

Next.js:

import { useRouter } from 'next/router'

function Page() {
  const router = useRouter()
  return <p>Post: {router.query.slug}</p>
}

export default Page

Blitz:

import { useParam } from "blitz"

function Page() {
  const slug = useParam("slug", "string")
  return <p>Post: {slug}</p>
}

export default Page

Both frameworks offer similar routing capabilities, but Blitz provides a more streamlined approach with its useParam hook, while Next.js requires the use of the useRouter hook and accessing the query object.

29,083

Build Better Websites. Create modern, resilient user experiences with web fundamentals.

Pros of Remix

  • Built-in server-side rendering (SSR) and code splitting for improved performance
  • Seamless integration with existing web standards and APIs
  • More flexible routing system with nested routes and layouts

Cons of Remix

  • Steeper learning curve, especially for developers new to SSR concepts
  • Less opinionated structure, which may require more setup and configuration
  • Smaller ecosystem and community compared to Blitz

Code Comparison

Remix route example:

export default function Index() {
  return <h1>Welcome to Remix</h1>;
}

export function loader() {
  return json({ message: "Hello from loader" });
}

Blitz page example:

import { BlitzPage } from "@blitzjs/next";

const Home: BlitzPage = () => {
  return <h1>Welcome to Blitz</h1>;
};

export default Home;

Both Remix and Blitz are modern web frameworks built on top of React, but they have different approaches to building applications. Remix focuses on web standards and server-side rendering, while Blitz provides a more opinionated, full-stack solution with built-in authentication and database integration. The choice between the two depends on project requirements, team expertise, and desired development experience.

17,089

The App Framework for Startups

Pros of Redwood

  • Full-stack framework with a more opinionated structure, providing a cohesive development experience
  • Built-in support for GraphQL API, making it easier to build and manage APIs
  • Integrated testing framework with Jest, encouraging better testing practices

Cons of Redwood

  • Steeper learning curve due to its opinionated nature and unique conventions
  • Less flexibility in choosing database and ORM, as it's tightly coupled with Prisma
  • Smaller community compared to Blitz, potentially leading to fewer resources and third-party integrations

Code Comparison

Redwood API handler:

export const handler = async (event, context) => {
  return {
    statusCode: 200,
    body: JSON.stringify({ message: "Hello, Redwood!" }),
  }
}

Blitz API route:

import { api } from "blitz"

export default api((req, res) => {
  res.status(200).json({ message: "Hello, Blitz!" })
})

Both frameworks offer similar API handling capabilities, but Redwood uses a more AWS Lambda-like approach, while Blitz follows a Next.js-inspired pattern.

18,419

web development, streamlined

Pros of SvelteKit

  • Lighter weight and faster performance due to Svelte's compilation approach
  • Simpler learning curve with less boilerplate code
  • More flexible routing system with dynamic route parameters

Cons of SvelteKit

  • Smaller ecosystem and community compared to Blitz.js
  • Less opinionated, which may require more decision-making for developers
  • Lacks built-in authentication and authorization features

Code Comparison

SvelteKit route file:

<script>
  export let data;
</script>

<h1>{data.title}</h1>
<p>{data.content}</p>

Blitz.js page file:

import { useQuery } from 'blitz'
import getPost from 'app/posts/queries/getPost'

export default function Post({ id }) {
  const [post] = useQuery(getPost, { id })
  return (
    <>
      <h1>{post.title}</h1>
      <p>{post.content}</p>
    </>
  )
}

SvelteKit focuses on simplicity and performance, while Blitz.js provides a more comprehensive full-stack solution with built-in features. SvelteKit's approach may be more suitable for smaller projects or those requiring high performance, while Blitz.js might be better for larger, more complex applications that benefit from its integrated toolset and conventions.

54,014

The Intuitive Vue Framework.

Pros of Nuxt

  • More mature and established ecosystem with a larger community
  • Better documentation and learning resources
  • Seamless integration with Vue.js and its ecosystem

Cons of Nuxt

  • Less opinionated, requiring more configuration for complex setups
  • Lacks built-in authentication and database solutions
  • May have a steeper learning curve for beginners

Code Comparison

Nuxt route definition:

// pages/users/_id.vue
export default {
  async asyncData({ params }) {
    const user = await fetchUser(params.id)
    return { user }
  }
}

Blitz route definition:

// app/users/[id].js
import { useQuery } from 'blitz'
import getUser from 'app/users/queries/getUser'

export default function User({ id }) {
  const [user] = useQuery(getUser, { id })
  return <div>{user.name}</div>
}

Nuxt focuses on file-based routing and Vue.js components, while Blitz uses a more React-centric approach with built-in data fetching hooks. Blitz provides a more integrated full-stack experience, whereas Nuxt primarily focuses on the frontend with optional server-side rendering capabilities.

55,199

The best React-based framework with performance, scalability and security built in.

Pros of Gatsby

  • Extensive plugin ecosystem for easy integration of various features and data sources
  • Strong focus on performance optimization, including automatic code splitting and image optimization
  • Large and active community, providing extensive resources and support

Cons of Gatsby

  • Steeper learning curve, especially for developers new to GraphQL
  • Build times can be slow for large sites with many pages or complex data structures
  • Less suitable for dynamic content and frequently updated data

Code Comparison

Gatsby (Static Site Generation):

export const query = graphql`
  query {
    allMarkdownRemark {
      edges {
        node {
          frontmatter {
            title
          }
        }
      }
    }
  }
`

Blitz (Full-stack React Framework):

import { useQuery } from "blitz"
import getPosts from "app/posts/queries/getPosts"

const Posts = () => {
  const [posts] = useQuery(getPosts)
  return <PostList posts={posts} />
}

Gatsby uses GraphQL for data fetching, while Blitz leverages React Query for server-state management. Gatsby is primarily focused on static site generation, whereas Blitz provides a full-stack solution with built-in authentication, database integration, and API routes. Blitz offers a more Rails-like developer experience with conventions and code generation, while Gatsby excels in creating static websites with optimized performance.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Blitz.js


The Missing Fullstack Toolkit for Next.js


Quick Start

Install Blitz

Run npm install -g blitz or yarn global add blitz

You can alternatively use npx

Create a New App

  1. blitz new myAppName
  2. cd myAppName
  3. blitz dev
  4. View your brand new app at http://localhost:3000



Welcome to the Blitz Community 👋

The Blitz community is warm, safe, diverse, inclusive, and fun! LGBTQ+, women, and minorities are especially welcome. Please read our Code of Conduct.

Join our Discord Community where we help each other build Blitz apps. It's also where we collaborate on building Blitz itself.

For questions and longer form discussions, post in our forum.

There's still a lot of work to do, so you are especially invited to join us in building Blitz! A good place to start is The Contributing Guide.


Financial Contributors

Your financial contributions help ensure Blitz continues to be developed and maintained! We have monthly sponsorship options starting at $5/month.

👉 View options and contribute at GitHub Sponsors, PayPal, or Open Collective

🌱 Seedling Sponsors

🥉 Bronze Sponsors

🥈 Silver Sponsors

🏆 Gold Sponsors

💎 Diamond Sponsors


Core Team ✨


Brandon Bayer

Creator

Dillon Raphael

Siddharth Suresh avatar
Siddharth Suresh

Maintainers (Level 2) ✨

Code ownership, pull request approvals and merging, etc (see Maintainers L2)


Simon Knott

SuperJSON

JH.Lee

SuperJSON

Maintainers (Level 1) ✨

Issue triage, pull request triage, community encouragement and moderation, etc (see Maintainers L1)


Jeremy Liberman

Contributors ✨

Thanks to these wonderful people (emoji key):


Brandon Bayer

💻 🖋 🤔 👀 ⚠️ 📖

Rudi Yardley

💻 🤔 👀 ⚠️

Dylan Brookes

💻 🤔 👀 ⚠️ 📖

Adam Markon

💻 🤔 👀 ⚠️ 🚧

Corey Brown

💻 👀 🚧

Lori Karikari

💻 👀 🚧 📖

Elias Johansson

💻 👀 🚧

Michael Edelman

🚇 💻

Todd Geist

💵 💻

Robert Rosenberg

💻 🚧 📖

Beata Obrok

💻

Tahir Awan

💻

Camilo Gonzalez

💻

Daniel Kempner

💻

Giel

💻

Jeremy Liberman

💻 🚧 ⚠️ 📖

Jim Cummins

💻

Kristina Matuška

🎨

Jason Blalock

💻

aej11a

💻

marcoseoane

🤔

Rishabh Poddar

🤔

Lorenzo Rapetti

💻

Justin Hall

💻 📖

Sajjad Hashemian

💻

Eduardo Lopes

💻

Matthew Leffler

📖

Matt

📖

Sonny

📖

Fran Zekan

💻 📖

Jan Baykara

📖

Mike Perry Y Attara

📖

Devan

📖

Jack Clancy

💻 🚧

Nicolas Torres

⚠️ 💻 👀 📖

Simon Knott

💻 ⚠️ 🚧 📖

Jaga Santagostino

💻 📖 🚧

João Portela

💻

Da-Jin Chu

💻

Shinobu Hayashi

💻

Karan Kiri

💻

Alan Long

📖

codingsh

💻

Rafael Nunes

👀 💻

Simon Debbarma

🎨 🚧 📖

0xflotus

💻 📖

tmns

💻 📖

Jru Harris

📖

Ivan Medina

💻 🚧

Dwight Watson

💻 📖

Horie Issei

💻

Nhat Khanh

💻

Abu Uzayr

💻 📖

Nabiullah elham

💻

Lachlan Campbell

💻

Enzo Ferey

💻

Pierre Grimaud

💻

Andreas Adam

💻

Kevin Tovar

💻

Ante Primorac

💻 📖

Mykal Machon

💻

Jamie Davenport

💻 🚧

GaneshMani

💻

reymon359

💻

gvasquez11

💻

José Miguel Ochoa

💻

Oscar Sirvent

💻 📖

Daniel Molnar

📖 💻

Kevin Wu Won

📖

John Duong

💻

Noah Fleischmann

💻

Matsumoto Toshi

💻 📖

Simon Edelmann

💻

Shaun Church

📖 💻

Steven

📖

Sigurd Moland Wahl

💻

Brian Andrews

📖

Garrison Snelling

📖

Ty Lange-Smith

💻

Rubén Moya

💻 ⚠️

robertgrzonka

💻 🚇

Alex Orr

💻

Chris Tse

💻

Netto Farah

💻

Rohan Julka

🚇

Ivan Santos

💻

Soumyajit Pathak

💻

Sebastian Kurpiel

📖

Steffan

💻 📖 💵

Kristóf Poduszló

💻

Weilbyte

💻 📖

Ricardo Trejos

💻 📖

George Karagkiaouris

💻 📖

Brady Pascoe

💻

Jirka Svoboda

💻

Alan Alickovic

💻 📖

Yngve Høiseth

📖

Bruno Crosier

📖

Johan Schepmans

💻

Dillon Raphael

💻 📖 ⚠️

Cody G

💻 ⚠️

madflow

📖

Satoshi Nitawaki

💻 🚧 💬 📖

sirmyron

📖 💻

engelkes-finstreet

📖 💻 🚧

Denis Radin

👀 💻 📖

Michael Li

💻

yuta0801

💻

Obadja Ris

📖

Jose Felix

💻

John Cantrell

💻

Kwuang Tang

💻

John Letey

💻

Juan Di Toro

💻

Taylor Johnson

💻 📖

Sriram Thiagarajan

📖

Sergio Xalambrí

📖

Patrick G

💻

अभिनाश (Avinash)

💻

Enrico Schaaf

💻

Kitze

🤔

Mohamed Shaban

💻

Joris

💻

Valentin Funk

📖

Luke Bennett

💻

Haseeb Majid

💻

Phillipp Schmedt

💻

Piotr Monwid-Olechnowicz

💻

Kotaro Chikuba

💻 ⚠️

Konrad Kalemba

💻 📖

Alucard17

💻

Domantas Mauruča

⚠️ 💻

Stratulat Alexandru

💻 🚧

André Ericson

💻 📖

Carlos Fernández

📖

Kevin Østerkilde

📖 💻

aaronfulkerson

💻 💬

Alexandru Naiman

💻

David Ezekiel Lutta

💻

wanjuntham

💻

Victor Nahuel Chaves

💻

Peter Shih

💻

Seweryn Kalemba

💻

Nikhil Saraf

💻 📖

Zane

📖

Dulce Hernández

💻

Mark Hähnel

💻

Viktor Nemes

💻

Gabe O'Leary

📖

Lucas Machado

💻

maciek_grzybek

💻

Michael Weibel

💻

Hiroki Isogai

💻

matamatanot

📖

Eric Sakmar

📖

Simon Legg

📖

Robert Soriano

💻

Benedikt Schnatterbeck

💻

Talor Anderson

💻 📖

Akira Baruah

💻

Christopher Wray

💻

Piotrek Tomczewski

💻 📖

Raphaël Huchet

📖 ⚠️ 💻

Alex Johansson

💻

David Mazza

💻

Ray Andrew

💻 📖

Abdullah Mzaien

💻 📖

William Kwao

📖

Lukas Strassel

💻 ⚠️

Thibaut Patel

💻

Jon Stuebe

💻

Ugo Onali

📖

SaintMalik

📖

Khaled Garbaya

💻

tundera

💻 ⚠️ 📖

markylaing

💻 📖

Akifumi Sato

💻

Beep LIN

💻

Matt Wood

💻

Joaquin Bravo Contreras

💻

Arjun Dubey

💻

chanand

💻

phillipkregg

📖

Tim Reynolds

📖

Linbudu

📖

C Reimers

📖

Tsuyoshi Osawa

💻

Rembrandt Reyes

💻 📖 ⚠️

Toshiya Doi

📖

t.kuriyama

💻

Robert Malko

💻

Ranjan Purbey

💻

tarunama

💻

David Kramer

💻

Michael Esteban

📖

marina

📖 💻

Jonas Thiesen

📖

Yash Thakkar

💻

Kazuma Suzuki

🎨 💻

Yuji Matsumoto

📖

Gimel Dick

💻

Andreas Bollig

💻 📖

AJ Markow

⚠️ 💻

TagawaHirotaka

💻 ⚠️

Amr A.Mohammed

💻

Lucas Willems

📖 💻

Alistair Smith

💻

Rodrigo Ehlers

💻

Michael Ford

💻

Brian Liu

💻

Aleksandra Sikora

💻 📖 ⚠️

JuanM04

💻 📖 ⚠️

Arend de Boer

📖

Felipe Milani

📖

Joe Edelman

💻

Gary

📖

Oliver Lopez

📖

Andreas Zaralis

📖

David Torbeck

📖

Gustavo Gard

📖

Immortalin

💻

Cristian Granda

💻

Denise Yu

💻

Andrea Della Corte

📖

Adit Sachde

📖

Hiren Chauhan

💻

Mark Jackson

📖 💻

Lewis Blackburn

📖

Vytenis

💻

Matthieu

💻 ⚠️

Mitchell Johnson

💻

Roshan Manuel

💻 📖 ⚠️

Kevin Langley Jr.

💻 📖

Gabriel Picard

📖

Ryan Chenkie

📖

Santhosh B. Appan

📖

James Moran

💻 📖

Jack Zhao

💻

Hisaki Akaza

📖

Flavio

💻

Bhanu Teja Pachipulusu

💻

Pavel Struhar

💻

Reo Ishiyama

💻

Tom MacWright

📖 ⚠️ 💻

François Best

💻

Faraz Patankar

📖

Eric Vicenti

📖 💻

Alex Dolan

📖 💻 ⚠️

Mathis Pinsault

📖

gstranger

💻 📖

Mark Hughes

💻 📖

Andrea Rizzello

📖

Jahred Hope

📖

Simon El Nahas

📖

Buleandra Cristian

📖 💻

Pedro Enrique Palau Isaac

💻

sean-brydon

📖

Alessandro

📖

laubonghaudoi

📖

Tommaso Bruno

📖

Antony

📖

Fatih Altinok

📖

Mokshit Jain

💻

Muhammad Ubaid Raza

💻 📖

Nick Warren

💻

mlabate

📖

Lukas Spieß

📖

DawnOfMidnight

📖

Kenza Iraki

⚠️ 💻

Agusti Fernandez

💻

Anjianto

💻

Blanc Adrien

💻

meepdeew

📖

Hardik Gaur

📖

acornellier

💻

craigglennie

📖

Fernando Villasenor

💻

swiftgaruda

📖

Pankaj Patil

📖

Mina Abadir

💻 📖 ⚠️

Francesco Sardo

📖 💻

Nikolay

📖

Dipesh Wagle

💻

Benjamin Bender

💻

Nima Shoghi

💻

Andreas Thomas

📖

guoqqqi

📖

Tim

💻 ⚠️

Marek Orłowski

📖

Antoine G

💻

Sean Winner

💻 ⚠️ 📖

Max Programming

💻

Sebastian Hoitz

⚠️ 💻

garnerp

📖

kivi

💻

Dan Greaves

💻

Lukas Neumann

📖 💻 ⚠️

Dustin Bachrach

💻 📖

Ashikka Gupta

💻 ⚠️

Daniel Almaguer

📖

Kevin Peters

📖

Daniel Bannert

💻 📖

Benja Kugler

💻

Eric Semeniuc

⚠️ 💻

Ricardo Romero

📖

Moritz Reiter

📖

Matt Sichterman

📖

Kai Schlamp

📖 💻

Muyiwa Olu

💻

Rabbi Hossain

📖

bravo-kernel

💻 📖

Sam Holmes

💻

Miguel Cabrerizo

💻 📖

Zack Hobson

💻 📖

Mokhtar

📖

Ken Kuan

💻

meehawk

💻

Rahul Ravindran

💻

Ilya

💻 📖 ⚠️

Hashim Warren

📖

Damilola Randolph

📖

Matt Campbell

📖

(◕ᴥ◕)

💻

Mat Milbury

📖

Andreas Asprou

💻

Kot

💻 ⚠️ 📖

Amane

📖

John Leung

📖

Bruce

💻

Emily

💻

Nathan Verni

📖

Davy Engone

📖

Federico Joel Orlandau

📖 💻

John Murphy

📖 💻

martinsaxa

💻

Austin Walhof

📖

Geoffrey

💻 📖 ⚠️

Kevin Pham

📖

kimngan-bui

📖

Bahk Chanhee

💻

John Vandivier

💻 ⚠️ 📖

Namir

📖 💻 ⚠️

Scott Cooper

📖

Abduttayyeb M.r

📖

Mayuran

💻

Aleksei Vesselko

📖

Punn Siriphanthong

💻

Shawn Fetanat

📖

Moyuru

💻 ⚠️ 📖

Cam Sloan

📖

Maciek Sitkowski

📖

Vivek

📖 💻

CJ Lazell

💻

Robert

📖

Christian Jensen

📖

Devin Rasmussen

💻

Thomas Brenneur

💻 📖 ⚠️

Lucas Vazquez

💻

Chris Johnson

📖

Rob Stevenson

📖

Lucas Heymès

💻 📖

Lasse Norfeldt

📖

Péter Nyári

📖 💻

Holger Frohloff

📖

Basil Khan

📖

Daniel Esteves

📖

Cory House

📖

Austin (Thang Pham)

📖

Marcus Reinhardt

📖 💻

David Christie

📖

Ajanth

📖

Div

📖

David Arteaga

📖

Mukul Kolpe

💻

tyler

💻

Sofiane Djellouli

📖

kreako

📖

Sarah Dayan

💻

Cristi Ciobanu

📖

Arpit Dalal

📖

robertrisch

📖

saadaltabari

📖 💻

Jeeho Ahn

📖 🔧 💻

Ryan Washburne

📖

Shundan Xiao

📖

tommywong-dev

📖

Datner

📖 💻

Chaiwat Trisuwan

📖 💻

Daniel Oltmanns

📖 💻

Edrick Leong

📖 💻 ⚠️

Siddharth Suresh

📖 💻 ⚠️ 🚧

JH.Lee

💻 ⚠️ 🚧 📖

Cory Deppen

📖

oloost

📖

Jan Vennemann

📖 💻

Kevin Jones

📖

Paul

📖 💻 ⚠️

Selçuk Fatih Sevinç

📖 💻

usamaster

📖

Andrew Glago

📖 💻

Tobias

💻 📖 ⚠️

Iagor Moraes

📖 💻

Dawid Urbaniak

📖 💻

Jhonny Michel

📖 💻 ⚠️

sweetliquid

💻

Sakamoto, Kazunori

📖 💻

Johan Eliasson

📖

Hikmat Jafarli

📖 💻

Maotora ᕙ(⇀‸↼‶)ᕗ

📖 💻

Vitalie

📖 💻

Nelson Estevão

📖 💻

David

📖 💻 ⚠️

G.J. Moed

📖 💻

Tetsuya Fukuda

📖 💻

Nikita Kamaev

📖

Nikola Ivanov

📖

Jakub Mazurek

📖 💻

Maciej Kasprzyk

📖 💻

Justin Smid

📖 💻

rodobre

📖 💻

Zamfira Costin-Andrei

📖 💻

Sergey

📖

Savvas Papageorgiadis

📖 💻

Leonidas

📖 💻

Doc0x1

📖 💻

Luis Isea

📖 💻

Jiawen Geng

📖 💻

Tim Neutkens

📖 💻 ⚠️

Aviv Keller

💻

bezalel6

📖 💻

This project follows the all-contributors specification. Contributions of any kind welcome!

NPM DownloadsLast 30 Days