Feb 10, 2023
James Perkins
Introducing @clerk/fastify , Redwood v4 support, Next.js Middleware page protection and improvements to components.
The team has been making improvements to the Clerk product and introducing new packages, here is a round up from the last two weeks.
@clerk/fastify
We had a a number of requests recently for a dedicated package for Fastify and as of today you can now use Clerk with Fastify using our latest package.
To learn how it works check out our new getting started guide in our docs
Our Clerk integration for Redwood has been upgraded to be able to support Redwood V4. With that you can check out the latest integration guide in the Redwood documentation.
We introduced middleware as a way to protect pages during the month of November, after a few tweaks and improvements. We are happy to announce this is now the recommended way to protect your pages. Below is an example of using Clerk + Middleware together.
middleware.ts1import { withClerkMiddleware, getAuth } from '@clerk/nextjs/server'2import { NextResponse } from 'next/server'3import type { NextRequest } from 'next/server'45// Set the paths that don't require the user to be signed in6const publicPaths = ['/', '/sign-in*', '/sign-up*']78const isPublic = (path: string) => {9return publicPaths.find(x =>10path.match(new RegExp(`^${x}$`.replace('*$', '($|/)')))11)12}1314export default withClerkMiddleware((request: NextRequest) => {15if (isPublic(request.nextUrl.pathname)) {16return NextResponse.next()17}18// if the user is not signed in redirect them to the sign in page.19const { userId } = getAuth(request)2021if (!userId) {22// redirect the users to /pages/sign-in/[[...index]].ts2324const signInUrl = new URL('/sign-in', request.url)25signInUrl.searchParams.set('redirect_url', request.url)26return NextResponse.redirect(signInUrl)27}28return NextResponse.next()29})3031export const config = { matcher: '/((?!.*\\.).*)' }
The Control Components strategy can continued to be used and we have no plans to remove this strategy.
We made some improvements to the Clerk components now if a user opens any Clerk component in a modal on a mobile phone they will present with a cross in the top right corner to close them.
User impersonation is now only accessible in the Clerk dashboard if the user has the role of admin or is in their own personal space.
The best way to keep up with Clerk is to subscribe to our newsletter. We send out updates every week. Updates include new features, what we have been working on, and blog posts you may have missed!
Clerk has a community Discord
Our Twitter account (@clerkdev) announces the latest features and improvements. We would also be psyched if you tagged us in projects you have built.
Start completely free for up to 10,000 monthly active users and up to 100 monthly active orgs. No credit card required.
Learn more about our transparent per-user costs to estimate how much your company could save by implementing Clerk.
The latest news and updates from Clerk, sent to your inbox.