How to Create a Next.js App in the Current Directory

Last updated on May 21, 2022 A Goodman Loading... One comment

You can initialize a new Next.js app in the current directory by using a dot (.) for the path when running the npx create-next-app command. There is a mandatory requirement is that the name of the current folder must not contain special characters, spaces, or capital letters.

npx create-next-app .

I ran the command above inside a folder named example and here’s what I got:

If you want to create a Next app with TypeScript, just add either the –ts or –typescript flag:

npx create-next-app . --typescript

After the initialization is complete, you can boots your project up by running the following command (without switching directory):

npm run dev

That’s it. Further reading:

You can also check our React topic page and Next.js topic page for the latest tutorials and examples.

Subscribe
Notify of
guest
1 Comment
Inline Feedbacks
View all comments
Nikos
Nikos
4 months ago

What if the current directory is non empty

You May Also Like