Changelog Feb 10, 2023

Category
Company
Published

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.

Introducing @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 or our fastify starter repository.

Redwood v4 support

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.

Next.js middleware protection strategy

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.ts
import { withClerkMiddleware, getAuth } from '@clerk/nextjs/server'
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'

// Set the paths that don't require the user to be signed in
const publicPaths = ['/', '/sign-in*', '/sign-up*']

const isPublic = (path: string) => {
  return publicPaths.find((x) => path.match(new RegExp(`^${x}$`.replace('*$', '($|/)'))))
}

export default withClerkMiddleware((request: NextRequest) => {
  if (isPublic(request.nextUrl.pathname)) {
    return NextResponse.next()
  }
  // if the user is not signed in redirect them to the sign in page.
  const { userId } = getAuth(request)

  if (!userId) {
    // redirect the users to /pages/sign-in/[[...index]].ts

    const signInUrl = new URL('/sign-in', request.url)
    signInUrl.searchParams.set('redirect_url', request.url)
    return NextResponse.redirect(signInUrl)
  }
  return NextResponse.next()
})

export const config = { matcher: '/((?!.*\\.).*)' }

The Control Components strategy can continued to be used and we have no plans to remove this strategy.

Clerk Component improvements

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.

Changes to User Impersonation

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.

How to stay up to date with Clerk?

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 Community Discord

Clerk has a community Discord. When you join, you will find a place:

  • Find the latest Clerk news and announcements
  • Share your project with the Clerk community, and talk about your experience
  • Request features and gets help integrating Clerk from the team and community.

Clerk Twitter

Our Twitter account (@clerkdev) announces the latest features and improvements. We would also be psyched if you tagged us in projects you have built.