DEV Community

Ryo Kuroyanagi
Ryo Kuroyanagi

Posted on

2

Legacy pages/api works in App Router Next.js project

TL;DR

pages/api directory works even in projects that are using App Router.

Why I wrote this doc?

I tried to use Auth0 library in my Next.js project and I'm using App Router. I faced a problem that I can not use Auth0 library in the manner of app directory API routing because the library provides only a handler for the legacy pages/api. However, I noticed that even in the project, I can use the legacy pages/api directory.

This is my example code.

Hope this helps.

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay