If you are not sure if yarn is already installed, open a command line and run the following.
yarn version
If yarn is not installed you want to run the following command.
npm install --global yarn
To create a project with typescript out of the box you can run the following command once you get to the directory you want to use in the command line.
yarn create next-app --typescript app-namecd app-nameyarn devcode .
Add baseUrl to tsconfig.json to allow absolute imports then add your paths.
"baseUrl": ".","paths": {"@components": ["components/*"],"@pages": ["pages/*"],"@utils": ["utils/*"],"@store": ["store/*"],"@images": ["images/*"],"@styles": ["styles/*"]}
Add new file .env.local touch .env.local
or echo > .env.local
.
NEXT_PUBLIC_BASE_URL="http://localhost:3000"
If you want to setup ESLint and Prettier you can run the following command. This will help you write better code.
yarn eslint .yarn add -D @typescript-eslint/eslint-plugin prettier eslint-config-prettier @typescript-eslint/parser
If you are using Visual Studio Code you can create a VSCode settings file to auto Prettier if you would like. .vscode/settings.json
touch .vscode/settings.json
or echo > .vscode/settings.json
{"editor.codeActionsOnSave": {"source.fixAll.eslint": true},"editor.formatOnSave": true,"editor.defaultFormatter": "esbenp.prettier-vscode"}
Edit .eslintrs.json
{"plugins": ["@typescript-eslint"],"extends": ["next/core-web-vitals","plugin:@typescript-eslint/recommended","prettier"],"rules": {"@typescript-eslint/no-unused-vars": "error","@typescript-eslint/no-explicit-any": "error"}}
Create .prettierrc.json
touch .prettierrc.json
or echo > .prettierrc.json
{"semi": true,"trailingComma": "es5","singleQuote": false,"tabWidth": 2,"useTabs": false}
To install Tailwind you can run the following command.
yarn add -D tailwindcss postcss autoprefixer @tailwindcss/forms @tailwindcss/typography @tailwindcss/line-clamp @tailwindcss/aspect-ratio @headlessui/react react-icons clsxnpx tailwindcss init -p
Edit tailwind.config.js
/** @type {import('tailwindcss').Config} */// eslint-disable-next-line @typescript-eslint/no-var-requiresconst colors = require("tailwindcss/colors");const brandColor = colors.blue;module.exports = {// Add support for dark mode, toggled via a class:// https://tailwindcss.com/docs/dark-modedarkMode: "class",// Inform Tailwind of where our classes will be defined:// https://tailwindcss.com/docs/optimizing-for-productioncontent: ["./pages/**/*.{js,ts,jsx,tsx}","./components/**/*.{js,ts,jsx,tsx}",],theme: {extend: {colors: {// NOTE: We modify the gray color, as the default Tailwind gray color is heavily saturated// with blue, which makes it look strange in dark mode. This gray color is more balanced,// and works better for sites supporting dark mode.gray: colors.gray,// Add a new "brand" color to all Tailwind utilities, so that we can easily change it.brand: brandColor,},// Modify the default ring color so that it matches the brand color:ringColor: {DEFAULT: brandColor["500"],},},},// Add some basic Tailwind plugins to add additional features:plugins: [require("@tailwindcss/forms"),require("@tailwindcss/line-clamp"),require("@tailwindcss/typography"),require("@tailwindcss/aspect-ratio"),],};
Edit styles/global.css
@tailwind base;@tailwind components;@tailwind utilities;#__next {min-height: 100%;}
You can safely delete Home.module.css as we will not need that with tailwind.
Modify pages/index.tsx
import type { NextPage } from "next";import Head from "next/head";const Home: NextPage = () => {return (<><Head><title>Site Title</title><meta name="description" content="Site Description" /></Head><h1 className="text-3xl font-bold underline">Hello world!</h1></>);};export default Home;
Create pages/_document.tsx
import { Head, Html, Main, NextScript } from "next/document";export function Document() {return (<HtmlclassName="h-full scroll-smooth bg-white antialiased [font-feature-settings:'ss01']"lang="en"><Head><link rel="preconnect" href="https://fonts.googleapis.com" /><linkrel="preconnect"href="https://fonts.gstatic.com"crossOrigin="anonymous"/><linkrel="stylesheet"href="https://fonts.googleapis.com/css2?family=Inter:wght@100..900&family=Lexend:wght@400;500&display=swap"/><link rel="icon" href="/favicon.ico" /><linkrel="apple-touch-icon"sizes="180x180"href="/apple-touch-icon.png"/><linkrel="icon"type="image/png"sizes="32x32"href="/favicon-32x32.png"/><linkrel="icon"type="image/png"sizes="16x16"href="/favicon-16x16.png"/><link rel="manifest" href="/site.webmanifest"></link></Head><body className="flex h-full flex-col"><Main /><NextScript /></body></Html>);}export default Document;
Edit pages/_app.tsx
import { useState, useEffect } from "react";import "@styles/globals.css";import type { AppProps } from "next/app";function MyApp({ Component, pageProps }: AppProps) {const [isSSR, setIsSSR] = useState(true);useEffect(() => {setIsSSR(false);}, []);if (isSSR) return null;return (<><Component {...pageProps} /></>);}export default MyApp;
yarn add axios
yarn add react-hot-toast
yarn add next-themes
yarn add formik
yarn add uuid
and yarn add @types/uuid -D
yarn dev
yarn build
yarn start
yarn deploy
Quick Links
Legal Stuff