⚡️ The Missing Fullstack Toolkit for Next.js
Blitz does not require any breaking changes with the major upgrade of Next 12
➔ Next 13
for usage with the pages directory. You can even continue to use the old blitz layout with all your files in app. But you'll need to rename that directory if you want to use the new Next.js app router.
Read More about usage of Blitz Toolkit with Next 13
From this release, the blitz toolkit will work out of the box with react server components.
getBlitzCtx
to access the auth context in server componentsuseAuthenticatedBlitzContext
to provide authorization utilities for server componentsBlitzProvider
to be wrapped in the RootLayout
present in the (root)/layout.ts file.invoke
method to work when called inside a React Server Componentacc07ce: This updates the suspense patch to work with Next.js 13.2+. Hopefully, soon we can stop patching once Next.js catches up with all the other frameworks and properly exposes the onRecoverableError react hook.
9529dbd: Introducing a new import path for the Blitz wrapper SecurePassword
to fully decouple the library from @blitzjs/auth
-import {SecurePassword} from "@blitzjs/auth"
+import {SecurePassword} from "@blitzjs/auth/secure-password"
Automatically upgrade using codemod (Make sure to git commit before running this command to avoid losing changes)
npx @blitzjs/codemod secure-password
Blitz now provides an adapter that allows you to use any NextAuth Provider with Blitz session management in any Nextjs application. Blitz session management gives you a lot more flexibility & control than NextAuth does.
// src/pages/api/auth/[...nextauth].ts
import { api } from "src/blitz-server"
import { NextAuthAdapter } from "@blitzjs/auth/next-auth"
import GithubProvider from "next-auth/providers/github"
import db, { User } from "db"
import { Role } from "types"
// Has to be defined separately for `profile` to be correctly typed below
const providers = [
GithubProvider({
clientId: process.env.GITHUB_CLIENT_ID as string,
clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
}),
]
export default api(
NextAuthAdapter({
successRedirectUrl: "/",
errorRedirectUrl: "/error",
providers,
callback: async (user, account, profile, session) => {
...
},
})
)
The Blitz generator has been completely overhauled to be more flexible, customizable and easier to use.
The comes as a cumulative effort from the work started by @Maastrich in https://github.com/blitz-js/blitz/pull/2134 then continued and enhanced by @Roesh in https://github.com/blitz-js/blitz/pull/2679 and finally fixed and polished by @siddhsuresh in https://github.com/blitz-js/blitz/pull/3869 .
> blitz generate model [fieldName]:[type]:[attribute]
Usage
> blitz generate all project name
> blitz generate all project name:string description:string? active:boolean
# with parent
> blitz generate model task \
name \
completed:boolean:default=false \
belongsTo:project?
The generate command can also be run multiple times to add more fields to the model. The generator will then mention the changes that will be made to the model and ask for confirmation before proceeding.
ea7561b: New schema.ts
file will be generated with the required zod
schemas that can be used independently with the mutations, queries and components.
This fixes the problem of not being able to import the schemas defined in the mutations due to the RPC compilation
6e88a84: Fixed security vulnerabilities in passport-adapter by upgrading passport and jsonwebtoken.
cadefb8: Fix failing tests due to the error NextRouter is not mounted in next 13 blitz apps.
enum
issue with postgresql Prisma 4.6.0 drops and recreates enum field when running db
push even if the field has not changed prisma/prisma#16180This release was made possible by the following contributors:
@flybayer, @siddhsuresh, @noxify, @tordans, @Vandivier, @exKAZUu
42a2cf951: BREAKING CHANGE: secure-password is now an optional peerDependency
, if you are using SecurePassword
api, you need to now install secure-password
in your application.
npm install secure-password
This helps users who do not use SecurePassword from having native package build issues.
blitz g
input via an allow-list of characters; throw if unwanted characters are found. Prevents to break the blitz command by accident (https://github.com/blitz-js/blitz/issues/4021).currentPassword
to the default fields that are masked in the loggerincludeRPC
in monorepossrc
instead of app
folder for blitz generate custom-template
localStorage
access to not crash the applicationMockRouter
prop in test utilscodegen
patch for nextjs
versions 13-13.0.6href
property to the generated route manifest that will return a string of the pathname and include query params.authError
query param in Passport adapter.href
property to the generated route manifest that will return a string of the pathname and include query params.codegen
patch for nextjs
versions 13-13.0.6api
of tanstack invalidateQueries
GET
requests without params
and meta
keysrole
to authenticate
property of BlitzPage
to authenticate page with respect to the role of the user. String
value or Array
of strings can be passed to authorize users.role
to authenticate
property of BlitzPage
to authenticate page with respect to the role of the user. String
value or Array
of strings can be passed to authorize users.