-
-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Next.js 13 app router + @sentry/wizard breaks typing #307
Comments
Out of curiosity, will removing the test page fix this error again? I think we should add a test page to the app dir instead, if the router is used. |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
- fixes getsentry#307 - checks for appRouter as well - defaults to creating appRouter if neither page nor app router is detected
I have created PR fixing this issue - #385 |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nextjs
SDK Version
7.56.0
Framework Version
13.4.5
Link to Sentry event
No response
SDK Setup
No response
Steps to Reproduce
This bug appears in a Next 13 app router project using typescript and the App router exclusively.
Create a project and set up a dynamic route in the app directory. e.g. app/post/[id]/page.tsx
On the new page use the useParams() hook from next/navigation to get the id
const { id } = useParams();
This currently will be typed as a string. Running the build command should also be successful
Now run the sentry wizard as per the Sentry next.js setup instructions:
npx @sentry/wizard@latest -i nextjs
Now building will fail due to a type error. This is due to the wizard creating a test route in the pages directory.
We now have both a pages and app directory so next/navigation uses the "compat" types. id is no longer of type string
but instead is of type: Record<string, string, string[]> | null
This caveat should probably be documented in the Next.js setup instructions
Expected Result
An app router project to build successfully after running the sentry wizard
Actual Result
The text was updated successfully, but these errors were encountered: