I've been working on a project using Next.js with the ArcGIS API but ultimately reverted to using TanStack Router with Vite due to significant developer experience issues. While the production build works fine, the development process has been extremely frustrating.
Key Issues with Next.js
I’d prefer to continue using Next.js, but the current ArcGIS compatibility issues make it challenging. Any insights or workarounds would be greatly appreciated!
Solved! Go to Solution.
Things will get better 😀. We are migrating away from stencil for our web components beginning at version 4.32 so that should help with your Turbopack issues. We are also working on optimizing the web components to work better with frameworks. If you use react 19 for instance you will no longer need to use the react specific wrapper, you'll be able to use the normal native web components. I don't have any specific build optimization suggestions for you right now as I'm not all that familiar with Next.js but we are trying to make things better for framework users.
Things will get better 😀. We are migrating away from stencil for our web components beginning at version 4.32 so that should help with your Turbopack issues. We are also working on optimizing the web components to work better with frameworks. If you use react 19 for instance you will no longer need to use the react specific wrapper, you'll be able to use the normal native web components. I don't have any specific build optimization suggestions for you right now as I'm not all that familiar with Next.js but we are trying to make things better for framework users.
Fantastic! Thats really useful information to know! Especially regarding the switch away from StencilJS... To be blunt, the majority of any build/types/testing issues I've ever seen with ArcGIS seem to have come from the Stencil JS library 😁
Regarding react 19, I made a bit of an attempt to switch over to using the web components natively already! Currently its not been super clear to me whether there is a pattern we should be following for getting the types for the web components? In fact I've been rather hamfistedly adding them in myself 😬https://github.com/JonnyDawe/UK-Sewage-Map/blob/main/src/types/global.d.ts.
This implementation gives me the allowed props, but unfortunately strips out the actual types for them (everything ends up as any)... From my investigations it looked like a StencilJS build quirk, so maybe this will also get simpler!
At version 4.32 (or RC currently) you'll be able to get the React types (and some other frameworks) by including them using a /// comment or you could also add the types in the includes section of your tsconfig if you wanted to do it there.
I've been adding an arcgis.d.ts file in my src folder with this in it, but that's just my preferred way not official Esri advise
/// <reference types="@arcgis/map-components/types/react.d.ts" />
tsconfig.app.json
...,
"include": ["src", "node_modules/@arcgis/map-components/types/react.d.ts"]
...
Thanks - top tier answers!