Getting Started with Blitz
Disclaimer
Before getting started, you should know this is alpha software. Blitz is incomplete. There are rough spots and bugs. APIs may change. But you can build an app and deploy it to production. We're excited to see what you build!
If you have any issues at all, please join the Blitz Community Slack and tell us in the #help channel. If you get stuck and frustrated, please don't blame yourself. This documentation, and Blitz in general, is not yet fine-tuned for those with less experience. Eventually it will be because this is very important to us.
Introduction
Blitz is a Rails-like framework for building monolithic, fullstack React apps. The idea is that Blitz makes you extremely productive by doing as much set up and grunt work for you.
When building a Blitz app, you don’t have to think about “building an API” or “fetching data from your API”. You only think about writing functions that get and change data. And to use those functions in your component, import and call them like a regular function.
Blitz is built on Next.js, so if you are familiar with that, you will feel right at home.
Blitz App Development
Set Up Your Computer
- You need Node.js 12 or newer
- You need Postgres installed and running.
- On macOS, you can use
brew install postgres
or install Postgres.app
- On macOS, you can use
Create Your Blitz App
npm install -g blitz
oryarn global install blitz
- Run
blitz new myAppName
to create a new blitz app in themyAppName
directory cd myAppName
blitz start
- View your baby app at https://localhost:3000
Set Up Your Database
By default, Blitz uses Prisma 2 which is a strongly typed database client. You probably want to read the Prisma 2 documentation. Note, Prisma 2 is not required for Blitz. The only Prisma-Blitz integration is the blitz db
cli command. You can use anything you want, such as Mongo, TypeORM, etc.
- Open
db/prisma.schema
and add the following:
- Run
blitz db migrate
- If this fails, you need to change the
DATABASE_URL
value in.env
to whatever is required by your Postgres installation.
- If this fails, you need to change the
Generate the CRUD Files
CRUD = create, read, update, delete
- Run
blitz generate crud project
- Run
blitz generate crud task --parent project
- Open https://localhost:3000/projects to see the default project list page