VSCode Settings for Next.js Project

Do you find it difficult to navigate your NextJS project or do you get lost when you are editing multiple pages/routes/layouts/components at once? Look no further!

Custom Labels

VSCode supports custom labels for the files that are currently…


This content originally appeared on DEV Community and was authored by Max Wiggedal

Do you find it difficult to navigate your NextJS project or do you get lost when you are editing multiple pages/routes/layouts/components at once? Look no further!

Custom Labels

VSCode supports custom labels for the files that are currently being displayed. I have put together some labels that work amazingly with a typical NextJS project setup.

"workbench.editor.customLabels.patterns": {
  "**/app/**/layout.tsx": "${dirname(1)}/${dirname} - Layout",
  "**/app/**/page.tsx": "${dirname(1)}/${dirname} - Page",
  "**/app/**/route.ts": "${dirname(1)}/${dirname} - Route",
  "**/app/**/_components/**/*.tsx": "${filename} - ${dirname(2)}/${dirname(1)} - Component",
  "**/components/**/*.tsx": "${filename} - Component",
  "**/data-layer/**/*.ts": "${filename} - Data Layer",
  "**/entities/**/*.ts": "${filename} - Entity",
  "**/hooks/**/*.ts": "${filename} - Hook",
  "**/lib/**/*.ts": "${filename} - Library",
  "**/utils/**/*.ts": "${filename} - Utility",
  "**/env/**/*.ts": "${filename} - Environment"
}

You can always modify it to match your project needs!

To correctly setup the settings for your project create a directory called .vscode with a settings.json file inside of it. Then simply add your settings in there and it will apply for everyone in the project that uses VSCode.

NextJS TypeScript Version

Do not forget to set your TypeScript version to the one provided by NextJS. You can do so by opening the command palette in VSCode by pressing CTRL + SHIFT + P or F1 and then entering >TypeScript: Select TypeScript Version... after you have done so you want to select Use Workspace Version.

This will also add:

"typescript.tsdk": "node_modules\\typescript\\lib"

to settings.json in the .vscode directory of your project.

Result

Result

You can easily identify what file belongs to what directory and therefore you for example do not have multiple "page.tsx" that you have to guess which one is correct.


This content originally appeared on DEV Community and was authored by Max Wiggedal


Print Share Comment Cite Upload Translate Updates
APA

Max Wiggedal | Sciencx (2024-07-04T14:03:22+00:00) VSCode Settings for Next.js Project. Retrieved from https://www.scien.cx/2024/07/04/vscode-settings-for-next-js-project/

MLA
" » VSCode Settings for Next.js Project." Max Wiggedal | Sciencx - Thursday July 4, 2024, https://www.scien.cx/2024/07/04/vscode-settings-for-next-js-project/
HARVARD
Max Wiggedal | Sciencx Thursday July 4, 2024 » VSCode Settings for Next.js Project., viewed ,<https://www.scien.cx/2024/07/04/vscode-settings-for-next-js-project/>
VANCOUVER
Max Wiggedal | Sciencx - » VSCode Settings for Next.js Project. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/04/vscode-settings-for-next-js-project/
CHICAGO
" » VSCode Settings for Next.js Project." Max Wiggedal | Sciencx - Accessed . https://www.scien.cx/2024/07/04/vscode-settings-for-next-js-project/
IEEE
" » VSCode Settings for Next.js Project." Max Wiggedal | Sciencx [Online]. Available: https://www.scien.cx/2024/07/04/vscode-settings-for-next-js-project/. [Accessed: ]
rf:citation
» VSCode Settings for Next.js Project | Max Wiggedal | Sciencx | https://www.scien.cx/2024/07/04/vscode-settings-for-next-js-project/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.