This is a Vanilla JS Next.js project bootstrapped with create-next-app
, Storybook and TailwindCSS.
- Create the next app and use npm as the package manager:
npx create-next-app@latest next-storybook-example --use-npm
- Tooled
next.config.js
to support Sass - Installed Tailwind:
npm install -D tailwindcss postcss autoprefixer
- Run tailwind boot:
npx tailwindcss init -p
, which createstailwind.config.js
andpostcss.config.js
- Create
components/
folder - Add tailwind base classes to globals.classes
- Install Storybook:
npx init sb
, creates.storybook
folder - Customize Postcss config for Next
If you are doing server side rendering or client side fetches, any API url environment variable must be prepended with NEXT_PUBLIC_
or it will not interpolate successfully. See Environment Variables doc
Running the development server:
npm run dev
Running storybook
npm run storybook
Build Storybook
Open http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying pages/index.js
. The page auto-updates as you edit the file.
API routes can be accessed on http://localhost:3000/api/hello. This endpoint can be edited in pages/api/hello.js
.
The pages/api
directory is mapped to /api/*
. Files in this directory are treated as API routes instead of React pages.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
.//ROOT LEVEL
.gitignore
├── README.md
├── components // stores all components
├── hooks // context and hook functions
├── next.config.js // takes next plugins, wraps around webpack, configures your build and compilation
├── node_modules
├── package-lock.json
├── package.json
├── pages // page templates
├── api // api routes and handler functions, much like next's own express
├── public // static assets go here
├── styles
├── tailwind.config.js // configure tailwind in terms of theme and token values
├── postcss.config.js // for tree-shaking and minimizing CSS (dead-code elimination)
Add a lib/
or util/
folder if you would like!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.