Server Error - TypeError: t.default.createContext is not a function

Peter Prins
1 min readNov 7, 2022

This is part of my error remedy reference collection. I create this series as a personal reference and I share it in the hope this series could help you fix bugs more easily.

Description

When running a NextJS application and you receive the following error when browsing to a certain page:

The above error will also show up in your logs:

TypeError: t.default.createContext is not a function

Solution

Add “use client” to the top of your file.

"use client"// my code here

NextJS assumes a component is a Server Component unless you explicitly tell NextJS the component you want is a Client Component. When this particular error shows up, there is a big chance you’re actually writing a Client component. So try adding “use client” to the top of your file and see whether the error is resolved. To learn more about Server Components and Client Components see: https://beta.nextjs.org/docs/rendering/server-and-client-components .

System

  • NextJS: 13.0.2
  • React: 18.2.0

--

--

Peter Prins

Nerd Entrepreneur who loves to improve peoples’ lives with software. Passionate about software architecture and usability. Shares knowledge to help others.