Most of the developers that start with Nextjs are not aware of the abundance of Nextjs examples, that are part of the Nextjs GitHub repo. You can use a handy CLI tool create-next-app
to get any example running in seconds.
Where Can You Find Nextjs Examples?
If you want quickly browse all the examples, you can find them in the examples
folder here.
Yet, there is a better way. Simply go to https://nextjs.org/examples. If you scroll down a bit, you will find a nifty filter.
Pretty neat, huh?
Here you can filter examples by:
- Styling
- Data Fetching
- Authentication
- CMS
- Next.js Features
- Database
- State Management
- Misc
How to Use Create Next App with an Example?
Nextjs has built an awesome CLI tool that makes it easy to get started in seconds.
npx create-next-app@latest
# or
yarn create next-app
If you want to start a project with an example, you can do it like this.
npx create-next-app@latest --example [name]|[github-url]
# or
yarn create next-app --example [name]|[github-url]
Let's do this with a real working example (no pun intended).
yarn create next-app --example auth0 auth0-app
This will simply create a new Nextjs app located in auth0-app
folder. The example auth0
will be already pre-installed.
Bonus
The benefit of using the CLI tool is that you can combine it with many other options. For example, you could add a --ts
flag to have typescript also included in your project.
You can read more about other options here.
I hope that Next time (sorry, no pun intended, again) you will be looking for a Nextjs example, you will know where to start.
Happy hacking!
Top comments (0)