New May 20, 2026

Next.js API route getting called multiple times in development mode [duplicate]

Libraries, Frameworks, etc. All from Newest questions tagged reactjs - Stack Overflow View Next.js API route getting called multiple times in development mode [duplicate] on stackoverflow.com

I am working on a Next.js application with App Router and noticed that my API route is getting called twice during development.

I have a simple fetch inside useEffect:

useEffect(() => {
  fetchUsers()
}, [])

Inside fetchUsers() I call my API route:

const fetchUsers = async () => {
  const res = await fetch('/api/users')
  const data = await res.json()
  console.log(data)
}

The issue is that the API route logs twice in the terminal even though the component renders once visually.

I checked:

Is this related to React Strict Mode in Next.js development mode, or am I missing something else?

Using:

Scroll to top