GithubHelp home page GithubHelp logo

ixartz / next-js-boilerplate Goto Github PK

View Code? Open in Web Editor NEW
7.2K 48.0 1.3K 9.26 MB

πŸš€πŸŽ‰πŸ“š Boilerplate and Starter for Next.js 14+ with App Router and Page Router support, Tailwind CSS 3.4 and TypeScript ⚑️ Made with developer experience first: Next.js + TypeScript + ESLint + Prettier + Husky + Lint-Staged + Jest + Testing Library + Cypress + Storybook + Commitlint + VSCode + Netlify + PostCSS + Tailwind CSS

Home Page: https://nextjs-boilerplate.com

License: MIT License

JavaScript 6.34% TypeScript 93.21% CSS 0.10% Shell 0.35%
nextjs next-theme next-js starter-kit starter-template starter-project boilerplate boilerplate-code jamstack netlify-template

next-js-boilerplate's Introduction

Boilerplate and Starter for Next.js 14+, Tailwind CSS 3.4, and TypeScript.

Next js starter banner

πŸš€ Boilerplate and Starter for Next.js with App Router support, Tailwind CSS, and TypeScript ⚑️ Prioritizing developer experience first: Next.js, TypeScript, ESLint, Prettier, Husky, Lint-Staged, Jest, Testing Library, Commitlint, VSCode, PostCSS, Tailwind CSS, Authentication with Clerk, Database with DrizzleORM (SQLite, PostgreSQL, and MySQL) and Turso, Error Monitoring with Sentry, Logging with Pino.js and Log Management with Better Stack, Monitoring as Code with Checkly, Storybook, Multi-language (i18n), and more.

Clone this project and use it to create your own Next.js project. You can check a Next js templates demo.

Sponsors

Clerk – Authentication & User Management for Next.js Turso - SQLite for Production Crowdin
Sentry Codecov PostHog Better Stack
Upstash Checkly React SaaS Boilerplate Next.js
Add your logo here

Features

Developer experience first, extremely flexible code structure and only keep what you need:

  • ⚑ Next.js with App Router support
  • πŸ”₯ Type checking TypeScript
  • πŸ’Ž Integrate with Tailwind CSS
  • βœ… Strict Mode for TypeScript and React 18
  • πŸ”’ Authentication with Clerk: Sign up, Sign in, Sign out, Forgot password, Reset password, and more.
  • πŸ“¦ Type-safe ORM with DrizzleORM, compatible with SQLite, PostgreSQL, and MySQL
  • πŸ’½ Global Database with Turso
  • 🌐 Multi-language (i18n) with next-intl and Crowdin
  • ♻️ Type-safe environment variables with T3 Env
  • ⌨️ Form handling with React Hook Form
  • πŸ”΄ Validation library with Zod
  • πŸ“ Linter with ESLint (default Next.js, Next.js Core Web Vitals, Tailwind CSS and Airbnb configuration)
  • πŸ’– Code Formatter with Prettier
  • 🦊 Husky for Git Hooks
  • 🚫 Lint-staged for running linters on Git staged files
  • πŸš“ Lint git commit with Commitlint
  • πŸ““ Write standard compliant commit messages with Commitizen
  • 🦺 Unit Testing with Jest and React Testing Library
  • πŸ§ͺ Integration and E2E Testing with Playwright
  • πŸ‘· Run tests on pull request with GitHub Actions
  • πŸŽ‰ Storybook for UI development
  • 🚨 Error Monitoring with Sentry
  • β˜‚οΈ Code coverage with Codecov
  • πŸ“ Logging with Pino.js and Log Management with Better Stack
  • πŸ–₯️ Monitoring as Code with Checkly
  • 🎁 Automatic changelog generation with Semantic Release
  • πŸ” Visual testing with Percy (Optional)
  • πŸ’‘ Absolute Imports using @ prefix
  • πŸ—‚ VSCode configuration: Debug, Settings, Tasks and Extensions
  • πŸ€– SEO metadata, JSON-LD and Open Graph tags
  • πŸ—ΊοΈ Sitemap.xml and robots.txt
  • ⌘ Database exploration with Drizzle Studio and CLI migration tool with Drizzle Kit
  • βš™οΈ Bundler Analyzer
  • 🌈 Include a FREE minimalist theme
  • πŸ’― Maximize lighthouse score

Built-in feature from Next.js:

  • β˜• Minify HTML & CSS
  • πŸ’¨ Live reload
  • βœ… Cache busting

Philosophy

  • Nothing is hidden from you, so you have the freedom to make the necessary adjustments to fit your needs and preferences.
  • Easy to customize
  • Minimal code
  • SEO-friendly
  • πŸš€ Production-ready

Requirements

  • Node.js 18+ and npm

Getting started

Run the following command on your local environment:

git clone --depth=1 https://github.com/ixartz/Next-js-Boilerplate.git my-project-name
cd my-project-name
npm install

Then, you can run the project locally in development mode with live reload by executing:

npm run dev

Open http://localhost:3000 with your favorite browser to see your project.

Set up authentication

Create a Clerk account at Clerk.com and create a new application in Clerk Dashboard. Then, copy NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY and CLERK_SECRET_KEY into .env.local file (not tracked by Git):

NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_pub_key
CLERK_SECRET_KEY=your_clerk_secret_key

Now, you have a fully working authentication system with Next.js: Sign up, Sign in, Sign out, Forgot password, Reset password, Update profile, Update password, Update email, Delete account, and more.

Set up remote database

The project uses DrizzleORM, a type-safe ORM compatible with SQLite, PostgreSQL, and MySQL databases. By default, the project is set up to work seamlessly with libSQL, and for production purposes, it's integrated with Turso. The Next.js Boilerplate also enables a smooth transition to an alternative database provider if your project requires it.

First, you need to create a Turso account at Turso.tech and install the Turso CLI:

brew install tursodatabase/tap/turso
turso auth signup # Sign up to Turso

Then, create a new database:

turso db create nextjs-boilerplate

Now, you need to update the DATABASE_URL in .env file with the database URL provided by Turso:

turso db show nextjs-boilerplate --url

# .env
# DATABASE_URL=libsql://[RANDOM-CHARS]-[DB-NAME]-[ORG-NAME].turso.io

Finally, you also need to create a new environment variable DATABASE_AUTH_TOKEN in .env.local (not tracked by Git) with the auth token provided by Turso:

turso db tokens create nextjs-boilerplate

# .env.local
# DATABASE_AUTH_TOKEN=[your-auth-token]

Translation (i18n) setup

For translation, the project uses next-intl combined with Crowdin. As a developer, you only need to take care of the English (or another default language) version. Other languages are automatically generated and handled by Crowdin. You can use Crowdin to collaborate with your translation team or translate the messages yourself with the help of machine translation.

To set up translation (i18n), create an account at Crowdin.com and create a new project. In the newly created project, you will able to find the project ID. You'll also require to create a new Personal Access Tokens by going to Account Settings > API. Then, in your GitHub Actions, you need to define the following environment variables CROWDIN_PROJECT_ID and CROWDIN_PERSONAL_TOKEN.

After defining the environment variables in your GitHub Actions, your localization files will be synchronized with Crowdin everytime you push a new commit to the main branch.

Project structure

.
β”œβ”€β”€ README.md                       # README file
β”œβ”€β”€ .github                         # GitHub folder
β”œβ”€β”€ .husky                          # Husky configuration
β”œβ”€β”€ .storybook                      # Storybook folder
β”œβ”€β”€ .vscode                         # VSCode configuration
β”œβ”€β”€ migrations                      # Database migrations
β”œβ”€β”€ public                          # Public assets folder
β”œβ”€β”€ scripts                         # Scripts folder
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ app                         # Next JS App (App Router)
β”‚   β”œβ”€β”€ components                  # React components
β”‚   β”œβ”€β”€ libs                        # 3rd party libraries configuration
β”‚   β”œβ”€β”€ locales                     # Locales folder (i18n messages)
β”‚   β”œβ”€β”€ models                      # Database models
β”‚   β”œβ”€β”€ styles                      # Styles folder
β”‚   β”œβ”€β”€ templates                   # Templates folder
β”‚   β”œβ”€β”€ types                       # Type definitions
β”‚   β”œβ”€β”€ utils                       # Utilities folder
β”‚   └── validations                 # Validation schemas
β”œβ”€β”€ tests
β”‚   β”œβ”€β”€ e2e                         # E2E tests, also includes Monitoring as Code
β”‚   └── integration                 # Integration tests
β”œβ”€β”€ tailwind.config.js              # Tailwind CSS configuration
└── tsconfig.json                   # TypeScript configuration

Customization

You can easily configure Next js Boilerplate by making a search in the whole project with FIXME: for making quick customization. Here is some of the most important files to customize:

  • public/apple-touch-icon.png, public/favicon.ico, public/favicon-16x16.png and public/favicon-32x32.png: your website favicon, you can generate from https://favicon.io/favicon-converter/
  • src/utils/AppConfig.ts: configuration file
  • src/templates/BaseTemplate.tsx: default theme
  • next.config.mjs: Next.js configuration
  • .env: default environment variables

You have access to the whole code source if you need further customization. The provided code is only example for you to start your project. The sky is the limit πŸš€.

Commit Message Format

The project enforces Conventional Commits specification. This means that all your commit messages must be formatted according to the specification. To help you write commit messages, the project uses Commitizen, an interactive CLI that guides you through the commit process. To use it, run the following command:

npm run commit

One of the benefits of using Conventional Commits is that it allows us to automatically generate a CHANGELOG file. It also allows us to automatically determine the next version number based on the types of commits that are included in a release.

Testing

All unit tests are located with the source code inside the same directory. So, it makes it easier to find them. The project uses Jest and React Testing Library for unit testing. You can run the tests with:

npm run test

Integration & E2E Testing

The project uses Playwright for Integration and E2E testing. You can run the tests with:

npx playwright install # Only for the first time in a new environment
npm run test:e2e

Enable Edge runtime (optional)

The App Router folder is compatible with the Edge runtime. You can enable it by uncommenting the following lines src/app/layouts.tsx:

// export const runtime = 'edge';

For your information, the database migration is not compatible with the Edge runtime. So, you need to disable the automatic migration in src/libs/DB.ts:

if (process.env.NODE_ENV !== 'production') {
  await migrate(db, { migrationsFolder: './migrations' });
}

After disabling it, you are required to run the migration manually with:

npm run db:migrate

You also require to run the command each time you want to update the database schema.

Deploy to production

During the build process, the database migration is automatically executed. So, you don't need to run the migration manually. But, in your environment variable, DATABASE_URL and DATABASE_AUTH_TOKEN need to be defined.

Then, you can generate a production build with:

$ npm run build

It generates an optimized production build of the boilerplate. For testing the generated build, you can run:

$ npm run start

You also need to defined the environment variables CLERK_SECRET_KEY using your own key.

The command starts a local server with the production build. Then, you can now open http://localhost:3000 with your favorite browser to see the project.

Error Monitoring

The project uses Sentry to monitor errors. For development environment, you don't need to do anything: Next.js Boilerplate is already configured to use Sentry and Spotlight (Sentry for Development). All errors will be automatically sent to your local Spotlight instance. So, you can try the Sentry experience locally.

For production environment, you need to create a Sentry account and create a new project. Then, in next.config.mjs, you need to update the org and project attribute in withSentryConfig function. You also need to add your Sentry DSN in sentry.client.config.ts, sentry.edge.config.ts and sentry.server.config.ts.

Code coverage

Next.js Boilerplate relies on Codecov for code coverage reporting solution. To use Codecov, create a Codecov account and connect it to your GitHub account. On your Codecov dashboard, it should display a list of your repositories. Select the repository you want to enable Codecov for and copy the token. Then, in your GitHub Actions, you need to define the CODECOV_TOKEN environment variable and paste the token you copied.

Be sure to create the CODECOV_TOKEN as a Github Actions secret, do not paste it directly into your source code.

Logging

The project uses Pino.js for logging. By default, for development environment, the logs are displayed in the console.

For production environment, the project is already integrated with Better Stack to manage and query your logs using SQL. To use Better Stack, you need to create a Better Stack account and create a new source: go to your Better Stack Logs Dashboard > Sources > Connect source. Then, you need to give a name to your source and select Node.js as the platform.

After creating the source, you able to see your source token and copy it. Then, in your environment variabless, you can paste the token in LOGTAIL_SOURCE_TOKEN variable. Now, all your logs will be automatically sent and ingested by Better Stack.

Checkly monitoring

The project uses Checkly to ensure that your production environment is always up and running. At regular intervals, Checkly runs the tests ending with *.check.spec.ts extension and notifies you if any of the tests fail. Additionally, you have the flexibility to execute tests across multiple locations to ensure that your application is available worldwide.

To use Checkly, you must first create an account on their website. Once you have an account, you can set the CHECKLY_API_KEY environment variable in GitHub Actions by generating a new API key in the Checkly Dashboard. Additionally, you will need to define the CHECKLY_ACCOUNT_ID, which can also be found in your Checkly Dashboard under User Settings > General.

To complete the setup, make sure to update the checkly.config.ts file with your own email address and production URL.

Useful commands

Bundle Analyzer

Next.js Boilerplate comes with a built-in bundle analyzer. It can be used to analyze the size of your JavaScript bundles. To begin, run the following command:

npm run build-stats

By running the command, it'll automatically open a new browser window with the results.

Database Studio

The project is already configured with Drizzle Studio to explore the database. You can run the following command to open the database studio:

npm run db:studio

Then, you can open https://local.drizzle.studio with your favorite browser to explore your database.

Known warnings

webpack.cache.PackFileCacheStrategy

Warning: webpack.cache.PackFileCacheStrategy Serializing big strings (104kiB) impacts deserialization performance (consider using Buffer instead and decode when needed)

This warning is caused by using Clerk and next-intl middlewares. It only happens when both middlewares are used together.

VSCode information (optional)

If you are VSCode users, you can have a better integration with VSCode by installing the suggested extension in .vscode/extension.json. The starter code comes up with Settings for a seamless integration with VSCode. The Debug configuration is also provided for frontend and backend debugging experience.

With the plugins installed on your VSCode, ESLint and Prettier can automatically fix the code and show you the errors. Same goes for testing, you can install VSCode Jest extension to automatically run your tests and it also show the code coverage in context.

Pro tips: if you need a project wide type checking with TypeScript, you can run a build with Cmd + Shift + B on Mac.

Contributions

Everyone is welcome to contribute to this project. Feel free to open an issue if you have question or found a bug. Totally open to any suggestions and improvements.

License

Licensed under the MIT License, Copyright Β© 2024

See LICENSE for more information.

Sponsors

Clerk – Authentication & User Management for Next.js Turso - SQLite for Production Crowdin
Sentry Codecov PostHog Better Stack
Upstash Checkly React SaaS Boilerplate Next.js
Add your logo here

Made with β™₯ by CreativeDesignsGuru Twitter

Sponsor Next JS Boilerplate

next-js-boilerplate's People

Contributors

andrii-bodnar avatar arfianadam avatar arrofirezasatria avatar astrotars avatar co0ki3 avatar crowdin-bot avatar fadhilradh avatar francoismassart avatar ghevia01 avatar ingokpp avatar ixartz avatar l9c avatar luishdez avatar marcinmaruszewski avatar max-programming avatar mrhbs avatar notrab avatar phanuelmutuma avatar riolly avatar saratscheff avatar semantic-release-bot avatar sh1nj1 avatar sumantaparida avatar sunxyw avatar tonyaellie avatar zeevo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

next-js-boilerplate's Issues

Consistent Issue: Invalid Tailwind CSS classnames order

Every time I save the file, the order of Tailwind CSS classnames are automatically changed, even when they are correct. Like, every time. And each save scrambles them in an incorrect order.

Here's my .eslintrc:

{
  // Configuration for JavaScript files
  "extends": [
    "airbnb-base",
    "next/core-web-vitals", // Needed to avoid warning in next.js build: 'The Next.js plugin was not detected in your ESLint configuration'
    "plugin:prettier/recommended"
  ],
  "rules": {
    "prettier/prettier": [
      "error",
      {
        "singleQuote": true,
        "endOfLine": "auto"
      }
    ]
  },
  "overrides": [
    // Configuration for TypeScript files
    {
      "files": ["**/*.ts", "**/*.tsx"],
      "plugins": [
        "@typescript-eslint",
        "unused-imports",
        "tailwindcss",
        "simple-import-sort"
      ],
      "extends": [
        "plugin:tailwindcss/recommended",
        "airbnb-typescript",
        "next/core-web-vitals",
        "plugin:prettier/recommended"
      ],
      "parserOptions": {
        "project": "./tsconfig.json"
      },
      "rules": {
        "prettier/prettier": [
          "error",
          {
            "singleQuote": true,
            "endOfLine": "auto"
          }
        ],
        "react/destructuring-assignment": "off", // Vscode doesn't support automatically destructuring, it's a pain to add a new variable
        "jsx-a11y/anchor-is-valid": "off", // Next.js use his own internal link system
        "react/require-default-props": "off", // Allow non-defined react props as undefined
        "react/jsx-props-no-spreading": "off", // _app.tsx uses spread operator and also, react-hook-form
        "react-hooks/exhaustive-deps": "off", // Incorrectly report needed dependency with Next.js router
        "@next/next/no-img-element": "off", // We currently not using next/image because it isn't supported with SSG mode
        "@typescript-eslint/comma-dangle": "off", // Avoid conflict rule between Eslint and Prettier
        "@typescript-eslint/consistent-type-imports": "error", // Ensure `import type` is used when it's necessary
        "import/prefer-default-export": "off", // Named export is easier to refactor automatically
        "tailwindcss/classnames-order": [
          "warn",
          {
            "officialSorting": true
          }
        ], // Follow the same ordering as the official plugin `prettier-plugin-tailwindcss`
        "simple-import-sort/imports": "error", // Import configuration for `eslint-plugin-simple-import-sort`
        "simple-import-sort/exports": "error", // Export configuration for `eslint-plugin-simple-import-sort`
        "@typescript-eslint/no-unused-vars": "off",
        "unused-imports/no-unused-imports": "error",
        "unused-imports/no-unused-vars": [
          "error",
          { "argsIgnorePattern": "^_" }
        ]
      }
    },
    // Configuration for testing
    {
      "files": ["**/*.test.ts", "**/*.test.tsx"],
      "plugins": ["jest", "jest-formatting", "testing-library", "jest-dom"],
      "extends": [
        "plugin:jest/recommended",
        "plugin:jest-formatting/recommended",
        "plugin:testing-library/react",
        "plugin:jest-dom/recommended"
      ]
    }
  ]
}

Add `.devcontainer/devcontainer.json

  • A devcontainer.json file can install tools and runtimes, and perform other setup tasks that the project requires.
  • It installs all dependencies and runs the project automatically, allowing the developer to focus on coding.
  • As the project is a Boilerplate with Tailwind CSS, TypeScript, and Prettier, this file can install all of the required extensions in a matter of seconds.
  • A devcontainer.json file can be used to configure the development container for both codespaces and local development using Visual Studio Code.

You can try how it works by creating a codespace on the main branch in this repository.

image

Here is the link to the repository: https://github.com/PriyansuMaurya/Rick-and-Morty-App

Why use so many overrides in ESLint?

According to [.eslintrc](https://github.com/ixartz/Next-js-Boilerplate/blob/master/.eslintrc) there are a lot of overrides, why is that? Why not add extends and plugins directly?

Is there a lot to be overridden from following extends?

"airbnb-base",
"next/core-web-vitals", // Needed to avoid warning in next.js build: 'The Next.js plugin was not detected in your ESLint configuration'
"plugin:prettier/recommended"

How do you maximize lighthouse score?

I couldn't catch sign of efforts for maximizing lighthouse score as a nonexport view.

Would you please tell me how you have maximized lighthouse score?

Bad performace

After install the boilerplate, lighthouse performances are really bad. Even when I remove image, there is a Total Blocking Time not good.
I tested in incognito mode. Did anyone else tested it?

Can't lint .tsx files

Hi, thanks a lot for this boilerplate.
It works great except (at least for me) for validating/linting .tsx files.
The code compiles fine but I have a lot of inconsistent errors, here's an example:

image

Wondering if you had any pointers on how to solve this?
Thanks!

Next 18 n or i18n

Hi there. Thanks by the boilerplate.
It is possible to add multi language?
Next 18 n or i18n
And add redux or I should I use context API?

Thanks in advance
Best Shintaro

Headless ui not working with this boilerplate when updating to react 18

Hello all!
I'm using this boilerplate (excellent job btw) and i'm unable to make headlessUI work with it when upgrading to react 18.

In this codesandbox, the toggle works as expected:
https://codesandbox.io/s/winter-waterfall-qmxf7?file=/pages/index.js

But if you follow the following steps, it does not:

  1. clone https://github.com/ixartz/Next-js-Boilerplate

  2. yarn add @headlessui/react@next

  3. Add this somewhere in the index page

  const [isShowing, setIsShowing] = useState(false)
 ....

        <button onClick={() => setIsShowing((isShowing) => !isShowing)}>
          Toggle
        </button>

        <Transition show={isShowing}>I will appear and disappear.</Transition>    
  1. Test the toggle => it works
  2. update to react 18 beta => yarn add react-dom@next; yarn add react@next
  3. Now toggle does not work

Thanks!

Migrating to Vitest

It seems you recently start working on Playwright migration, which is great!

Next migration is to migrate from Jest to Vitest, since Vitest is reaching 1.0, currently in v1 beta

how to get updates

hey, I wonder if I have cloned the boilerplate a year ago, how am I getting the latest changes into my own project?

Live reload does not work

I forked the repo. Node version 16.15, npm version 8.5.5, Windows 10 Home, any browser, can't think of any other relevant info to give you.

Clone the repo, npm install, npm build, npm run start -
Webapp comes up on localhost:3000. Altered some text in the HTML, saved it to verify hot reload works. Text never updates. Refresh page, no update. The only way to get the page to update is to rebuild the app.

Am I missing something? Is there a config setting where I need to change it to do hot reloads or something?

Boilerplate without Typescript?

Hi there,
Thanks for making this amazing boilerplate for Next.js. Is it possible for you to create one using JavaScript instead?

Much appreciated

Parsing error tsconfig.json

Hi,
i am getting the following error at the beginning of each file

Parsing error: Cannot read file '........../src/tsconfig.json'.eslint

Can you help me?
I'm on WSL 2 (Ubuntu)

Nextjs 13 Router

This repository is using old routing structure, please update it, thank you in advance!

ESLint parsing error due to parserOptions config. Related to Cypress/Jest?

Hi, great boilerplate by the way. I am seeing this error when I run npm run lint. could it be related to the type check issues with Cypress and Jest?

./cypress/support/e2e.ts
Error: Parsing error: ESLint was configured to run on `<tsconfigRootDir>/cypress/support/e2e.ts` using `parserOptions.project`: <tsconfigRootDir>/../../../../../../users/carpedn/gitlab/boilerplates/next-js-boilerplate/tsconfig.json
However, that TSConfig does not include this file. Either:
- Change ESLint's list of included files to not include this file
- Change that TSConfig to include this file
- Create a new TSConfig that includes this file and include it in your parserOptions.project
See the TypeScript ESLint docs for more info: https://typescript-eslint.io/docs/linting/troubleshooting##i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file

Can't disable CSS purging

Hi!

I'm trying to disable CSS purging during development. I'm using the Chromium developer tools as a sort of WYSIWYG editor. The list of suggestions in the image below is populated with all the available CSS classes. Purging naturally strips that list down to those classes that are actually in the markup/code. Since this is for playing around with styling I haven't added to the files yet, I would need an unpurged version.

devtools

I've tried to simply set purge: false in the tailwind.config.js, but that gets me the webpack error

error - ./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[2].oneOf[9].use[1]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[2].oneOf[9].use[2]!./src/styles/main.css
TypeError: Cannot read properties of undefined (reading 'filter')

Setting purge: [] just removes all classes.

The object declaration

purge: {
    enabled: false,
    content: ['./src/**/*.{js,ts,jsx,tsx}'],
  },

behaves like using an Array, where everything is stripped when content is a filter that finds nothing (e.g. empty). enabled is completely ignored. So is the NODE_ENV variable. Accodring to the tailwind documentation (last paragraph), purging should in general only happen when NODE_ENV === 'production'. Checking directly in tailwind.config.js shows NODE_ENV === 'development', though.

Any ideas how I can disable purgin at all, when NODE_ENV === 'development'?

HookWebpackError: Cannot convert a Symbol value to a string

Hi, I am currently using your template for my project on GitHub. However, I have encountered an error while attempting to generate the next build using the command "npm run build".

The error message I am receiving is as follows:
HookWebpackError: Cannot convert a Symbol value to a string at makeWebpackError (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/webpack/bundle5.js:28:311139) at /Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/webpack/bundle5.js:28:105980 at eval (eval at create (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/webpack/bundle5.js:13:28867), <anonymous>:27:1) at /Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/webpack/bundle5.js:28:69387 at /Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/build/webpack/plugins/next-trace-entrypoints-plugin.js:441:143 -- inner error -- TypeError: Cannot convert a Symbol value to a string at Object.TemplateLiteral (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/@vercel/nft/index.js:1:67573) at async Object.BinaryExpression (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/@vercel/nft/index.js:1:59330) at async Object.ArrayExpression (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/@vercel/nft/index.js:1:58890) at async computePureStaticValue (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/@vercel/nft/index.js:1:21246) at async Object.enter (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/@vercel/nft/index.js:1:27364) at async AsyncWalker.visit (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/@vercel/nft/index.js:6:78333) at async AsyncWalker.visit (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/@vercel/nft/index.js:6:78791) at async AsyncWalker.visit (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/@vercel/nft/index.js:6:78872) at async AsyncWalker.visit (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/@vercel/nft/index.js:6:78872) at async AsyncWalker.visit (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/@vercel/nft/index.js:6:78791) caused by plugins in Compilation.hooks.processAssets TypeError: Cannot convert a Symbol value to a string at Object.TemplateLiteral (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/@vercel/nft/index.js:1:67573) at async Object.BinaryExpression (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/@vercel/nft/index.js:1:59330) at async Object.ArrayExpression (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/@vercel/nft/index.js:1:58890) at async computePureStaticValue (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/@vercel/nft/index.js:1:21246) at async Object.enter (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/@vercel/nft/index.js:1:27364) at async AsyncWalker.visit (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/@vercel/nft/index.js:6:78333) at async AsyncWalker.visit (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/@vercel/nft/index.js:6:78791) at async AsyncWalker.visit (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/@vercel/nft/index.js:6:78872) at async AsyncWalker.visit (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/@vercel/nft/index.js:6:78872) at async AsyncWalker.visit (/Users/user/Documents/sities/PFFT/PFFT.AI/node_modules/next/dist/compiled/@vercel/nft/index.js:6:78791)

I would greatly appreciate your assistance in resolving this issue. If you require any additional information or logs, please let me know, and I will be happy to provide them.

`{
"name": "pfft.ai",
"version": "3.9.0",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"build-stats": "cross-env ANALYZE=true npm run build",
"export": "next export",
"build-prod": "run-s clean build export",
"clean": "rimraf .next out",
"lint": "next lint",
"format": "next lint --fix && prettier '**/.{json,yaml}' --write --ignore-path .gitignore",
"check-types": "tsc --noEmit --pretty && tsc --project cypress --noEmit --pretty",
"test": "jest",
"commit": "cz",
"cypress": "cypress open",
"cypress:headless": "cypress run",
"e2e": "start-server-and-test dev http://localhost:3000 cypress",
"e2e:headless": "start-server-and-test dev http://localhost:3000 cypress:headless",
"storybook": "storybook dev -p 6006",
"storybook:build": "storybook build",
"storybook:serve": "http-server storybook-static --port 6006 --silent",
"serve-storybook": "run-s storybook:
",
"test-storybook:ci": "start-server-and-test serve-storybook http://localhost:6006 test-storybook",
"prepare": "husky install",
"postbuild": "next-sitemap"
},
"dependencies": {
"@guna81/react-ticker": "^3.4.1",
"@material-tailwind/react": "^2.0.1",
"@mui/material": "^5.12.2",
"@mui/x-data-grid": "^6.3.0",
"@stripe/react-stripe-js": "^2.1.1",
"@stripe/stripe-js": "^1.54.1",
"@stripe/ui-extension-sdk": "^8.7.0",
"@types/react-animate-on-scroll": "^2.1.5",
"@types/react-stripe-elements": "^6.0.6",
"animate.css": "^4.1.1",
"axios": "^1.4.0",
"bcrypt": "^5.1.0",
"bcryptjs": "^2.4.3",
"crypto-js": "^4.1.1",
"formik": "^2.4.2",
"jsonwebtoken": "^9.0.0",
"lodash": "^4.17.21",
"mongo-seeding": "^3.7.2",
"mongodb": "^5.5.0",
"mongoose": "^6.11.2",
"mongoose-data-faker": "^0.1.2",
"next": "^13.4.3",
"next-auth": "^4.22.1",
"next-connect": "^0.13.0",
"next-seo": "^5.15.0",
"next-sitemap": "^4.0.6",
"react": "^18.2.0",
"react-animation-on-scroll": "^5.1.0",
"react-card-flip": "^1.2.0",
"react-dom": "^18.2.0",
"react-google-recaptcha": "^3.1.0",
"react-icons": "^4.8.0",
"react-share": "^4.4.1",
"react-spinners": "^0.13.8",
"react-toastify": "^9.1.3",
"stripe": "^12.9.0",
"tw-elements": "^1.0.0-beta2",
"validator": "^13.9.0"
},
"devDependencies": {
"@commitlint/cli": "^17.5.1",
"@commitlint/config-conventional": "^17.4.4",
"@commitlint/cz-commitlint": "^17.5.0",
"@next/bundle-analyzer": "^13.3.0",
"@percy/cli": "^1.22.0",
"@percy/cypress": "^3.1.2",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@storybook/addon-essentials": "^7.0.2",
"@storybook/addon-interactions": "^7.0.2",
"@storybook/addon-links": "^7.0.2",
"@storybook/blocks": "^7.0.2",
"@storybook/nextjs": "^7.0.2",
"@storybook/react": "^7.0.2",
"@storybook/test-runner": "^0.10.0",
"@storybook/testing-library": "^0.0.14-next.2",
"@testing-library/cypress": "^9.0.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@types/bcrypt": "^5.0.0",
"@types/bcryptjs": "^2.4.2",
"@types/jest": "^29.5.0",
"@types/jsonwebtoken": "^9.0.2",
"@types/mongoose": "^5.11.97",
"@types/node": "^18.16.1",
"@types/react": "^18.0.33",
"@types/react-google-recaptcha": "^2.1.5",
"@types/validator": "^13.7.15",
"@typescript-eslint/eslint-plugin": "^5.57.1",
"@typescript-eslint/parser": "^5.57.1",
"autoprefixer": "^10.4.14",
"commitizen": "^4.3.0",
"cross-env": "^7.0.3",
"cssnano": "^6.0.0",
"cypress": "^12.9.0",
"eslint": "^8.37.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-next": "^13.3.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-cypress": "^2.13.2",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-jest-dom": "^4.0.3",
"eslint-plugin-jest-formatting": "^3.1.0",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-storybook": "^0.6.11",
"eslint-plugin-tailwindcss": "^3.11.0",
"eslint-plugin-testing-library": "^5.10.2",
"eslint-plugin-unused-imports": "^2.0.0",
"http-server": "^14.1.1",
"husky": "^8.0.3",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"lint-staged": "^13.2.0",
"npm-run-all": "^4.1.5",
"postcss": "^8.4.21",
"prettier": "^2.8.7",
"rimraf": "^4.4.1",
"semantic-release": "^19.0.5",
"start-server-and-test": "^2.0.0",
"storybook": "^7.0.2",
"tailwindcss": "^3.3.1",
"typescript": "^4.9.5"
},
"config": {
"commitizen": {
"path": "@commitlint/cz-commitlint"
}
},
"release": {
"branches": [
"main"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/npm",
{
"npmPublish": false
}
],
"@semantic-release/git",
"@semantic-release/github"
]
},
"author": "Ixartz (https://github.com/ixartz)"
}

Need a clearer component in the storybook.

image

I think the advantage of storybooks is to intuitively show what changes occur in various ways, such as changing props of components.

However, I don't think the current components are enough to show this behavior.

Of course, if users are already familiar with the storybook, they will use it without difficulty. However, I think the user base who is looking for boilerplate is mostly next(or.. react) beginners.

I think putting components such as very simple buttons with props in a storybook for them would also help react beginners accessing this project.

Failed to load plugin 'tailwindcss' declared in '.eslintrc#overrides[0]': Unexpected token '?'

Hi!

I've experienced a problem while bootstrapping this project.

The way to reproduce this error is to bootstrap a fresh version from this repo by using git clone. Install npm dependencies and try to execute npm run lint.

This occurs in such error:

Failed to load plugin 'tailwindcss' declared in '.eslintrc#overrides[0]': Unexpected token '?'

Do you have any clues on how to resolve this problem?

unable to get storybook working

Hi, thanks for the awesome template. Unfortunately, running storybook init doesn't add any of the correct directories. Any ideas?

Difficulty Using Template and Running Migrations on Vercel Deploy

Hello,

I'm having trouble understanding how to use the provided template, especially when it comes to populating the database and running migrations.

Details:

I've successfully deployed my app on Vercel.
I'm unsure about how to execute new migrations during each build on Vercel.
Questions:

Can someone provide a step-by-step guide on how to use the template to populate the database?
How can I ensure that new migrations are executed during each build on Vercel?
Any help or guidance would be greatly appreciated. Thank you!

Errors with PNPM straight out of the box

Thanks for this starter repo! Here's some errors I've found, and some workarounds I can suggest.

Using version 3.21.0 with commit hash ab2ace1.

Missing module: better-sqlite3

When trying to run pnpm db:push, it results in this error:

$ pnpm db:push

> [email protected] db:push C:\...\Next-js-Boilerplate
> drizzle-kit push:sqlite

drizzle-kit: v0.19.13
drizzle-orm: v0.28.6

node:internal/modules/cjs/loader:1075
  const err = new Error(message);
              ^

Error: Cannot find module 'better-sqlite3'
Require stack:
- C:\...\Next-js-Boilerplate\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\index.cjs
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at node_modules/.pnpm/@[email protected]/node_modules/@libsql/client/lib-esm/sqlite3.js (C:\...\Next-js-Boilerplate\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\index.cjs:43596:37)
    at __init (C:\...\Next-js-Boilerplate\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\index.cjs:9:56)
    at node_modules/.pnpm/@[email protected]/node_modules/@libsql/client/lib-esm/index.js (C:\...\Next-js-Boilerplate\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\index.cjs:51852:5)
    at __init (C:\...\Next-js-Boilerplate\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\index.cjs:9:56)
    at src/cli/commands/sqliteIntrospect.ts (C:\...\Next-js-Boilerplate\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\index.cjs:51875:5)
    at __init (C:\...\Next-js-Boilerplate\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\index.cjs:9:56) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\...\\Next-js-Boilerplate\\node_modules\\.pnpm\\[email protected]\\node_modules\\drizzle-kit\\index.cjs'
  ]
}

Node.js v18.16.0
 ELIFECYCLE  Command failed with exit code 1.

Solution

I don't know why it requires better-sqlite3, but a simple install does the trick:
pnpm add better-sqlite3

Unloaded environment variables

When running something like pnpm db:push, the drizzle.config.ts file is read. It does not have access to the environment variables by default and you can expect libsql to throw an error for an invalid db url. Quickest way to test:

...,
dbCredentials: {
    url: process.env.DATABASE_URL ?? "hardcode-the-actual-url-here-and-no-error-will-occur",
},

Solution

Use dotenv:

  1. pnpm add dotenv
  2. Add it to files that need env vars, that aren't bootstrapped by Next.js:
// eg. drizzle.config.ts

import "dotenv/config"

Now the env file will be read successfully.

Libsql: Failed To Compile

When running pnpm dev we aren't met with any errors. But once we navigate to /guestbook these errors arise and cause the app to fail to compile:

$ pnpm dev

> [email protected] dev C:\...\Next-js-Boilerplate
> next dev

  β–² Next.js 13.5.3
  - Local:        http://localhost:3000
  - Environments: .env

 βœ“ Ready in 3.6s
 βœ“ Compiled /src/middleware in 457ms (276 modules)
 βœ“ Compiled / in 813ms (285 modules)
 β—‹ Compiling /guestbook/page ...
 β¨― ./node_modules/.pnpm/@[email protected][email protected]/node_modules/@libsql/client/LICENSE
Module parse failed: Unexpected token (1:4)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> MIT License
|
| Copyright (c) 2023 libSQL

Import trace for requested module:
./node_modules/.pnpm/@[email protected][email protected]/node_modules/@libsql/client/LICENSE
./node_modules/.pnpm/[email protected]/node_modules/@libsql/ ./node_modules/.pnpm/node_modules/@libsql/ ./node_modules/@libsql/ ./node_modules/.pnpm/node_modules/@libsql/ sync ^\.\/.*$     
./node_modules/.pnpm/[email protected]/node_modules/libsql/index.js
./node_modules/.pnpm/@[email protected][email protected]/node_modules/@libsql/client/lib-esm/sqlite3.js
./node_modules/.pnpm/@[email protected][email protected]/node_modules/@libsql/client/lib-esm/node.js
./src/libs/DB.ts
./src/app/guestbook/page.tsx
 β¨― ./node_modules/.pnpm/@[email protected][email protected]/node_modules/@libsql/client/LICENSE
Module parse failed: Unexpected token (1:4)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> MIT License
|
| Copyright (c) 2023 libSQL

Import trace for requested module:
./node_modules/.pnpm/@[email protected][email protected]/node_modules/@libsql/client/LICENSE
./node_modules/.pnpm/[email protected]/node_modules/@libsql/ ./node_modules/.pnpm/node_modules/@libsql/ ./node_modules/@libsql/ ./node_modules/.pnpm/node_modules/@libsql/ sync ^\.\/.*$     
./node_modules/.pnpm/[email protected]/node_modules/libsql/index.js
./node_modules/.pnpm/@[email protected][email protected]/node_modules/@libsql/client/lib-esm/sqlite3.js
./node_modules/.pnpm/@[email protected][email protected]/node_modules/@libsql/client/lib-esm/node.js
./src/libs/DB.ts
./src/app/guestbook/page.tsx
 β¨― ./node_modules/.pnpm/@[email protected][email protected]/node_modules/@libsql/client/LICENSE
Module parse failed: Unexpected token (1:4)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> MIT License
|
| Copyright (c) 2023 libSQL

Import trace for requested module:
./node_modules/.pnpm/@[email protected][email protected]/node_modules/@libsql/client/LICENSE
./node_modules/.pnpm/[email protected]/node_modules/@libsql/ ./node_modules/.pnpm/node_modules/@libsql/ ./node_modules/@libsql/ ./node_modules/.pnpm/node_modules/@libsql/ sync ^\.\/.*$     
./node_modules/.pnpm/[email protected]/node_modules/libsql/index.js
./node_modules/.pnpm/@[email protected][email protected]/node_modules/@libsql/client/lib-esm/sqlite3.js
./node_modules/.pnpm/@[email protected][email protected]/node_modules/@libsql/client/lib-esm/node.js
./src/libs/DB.ts
./src/app/guestbook/page.tsx

No Solutions Yet

As mentioned in the links below, you should include the following in your Next.js config:

...,
experimental: {
  serverComponentsExternalPackages: ["libsql"]
},

This unfortunately does not resolve the error.

Some helpful links:

Conclusion

These errors occur straight out of the box with this repo and the latest versions of next and @libsql/client:

"drizzle-orm": "^0.28.6",
"next": "^13.5.2",
"@libsql/client": "^0.3.5"

Please let me know if I should split these issues up.

Building Failed

How i can resolve this ?

8:42:04 AM: Netlify Build
8:42:04 AM: ────────────────────────────────────────────────────────────────
8:42:04 AM: ​
8:42:04 AM: ❯ Version
8:42:04 AM: @netlify/build 29.20.11
8:42:04 AM: ​
8:42:04 AM: ❯ Flags
8:42:04 AM: baseRelDir: true
8:42:04 AM: buildId: 64f2caf35cc9ab448545aad2
8:42:04 AM: deployId: 64f2caf35cc9ab448545aad4
8:42:04 AM: ​
8:42:04 AM: ❯ Current directory
8:42:04 AM: /opt/build/repo
8:42:04 AM: ​
8:42:04 AM: ❯ Config file
8:42:04 AM: /opt/build/repo/netlify.toml
8:42:04 AM: ​
8:42:04 AM: ❯ Context
8:42:04 AM: production
8:42:04 AM: ​
8:42:04 AM: ❯ Installing plugins
8:42:04 AM: - @netlify/[email protected]
8:42:20 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
8:42:16 AM: ​
8:42:16 AM: ❯ Using Next.js Runtime - v4.40.1
8:42:17 AM: ​
8:42:17 AM: @netlify/plugin-nextjs (onPreBuild event)
8:42:17 AM: ────────────────────────────────────────────────────────────────
8:42:17 AM: ​
8:42:17 AM: No Next.js cache to restore.
8:42:17 AM: Netlify configuration property build.environment.NEXT_PRIVATE_TARGET value changed.
8:42:17 AM: ​
8:42:17 AM: (@netlify/plugin-nextjs onPreBuild completed in 47ms)
8:42:17 AM: ​
8:42:17 AM: build.command from netlify.toml
8:42:17 AM: ────────────────────────────────────────────────────────────────
8:42:17 AM: ​
8:42:17 AM: $ npm run build
8:42:17 AM: > [email protected] build
8:42:17 AM: > npm run db:migrate && next build
8:42:17 AM: > [email protected] db:migrate
8:42:17 AM: > tsx ./scripts/DbMigrate.ts
8:42:18 AM: Migration started
8:42:18 AM: Migration failed
8:42:18 AM: LibsqlError: URL_INVALID: The URL is not in a valid format
8:42:18 AM: at parseUri (/opt/build/repo/node_modules/@libsql/client/lib-cjs/uri.js:12:15)
8:42:18 AM: at expandConfig (/opt/build/repo/node_modules/@libsql/client/lib-cjs/config.js:13:30)
8:42:18 AM: at createClient (/opt/build/repo/node_modules/@libsql/client/lib-cjs/node.js:28:42)
8:42:18 AM: at main (/opt/build/repo/scripts/DbMigrate.ts:9:18)
8:42:18 AM: at (/opt/build/repo/scripts/DbMigrate.ts:23:1)
8:42:18 AM: at Object. (/opt/build/repo/scripts/DbMigrate.ts:27:2)
8:42:18 AM: at Module._compile (node:internal/modules/cjs/loader:1256:14)
8:42:18 AM: at Object.F (/opt/build/repo/node_modules/@esbuild-kit/cjs-loader/dist/index.js:1:941)
8:42:18 AM: at Module.load (node:internal/modules/cjs/loader:1119:32)
8:42:18 AM: at Module._load (node:internal/modules/cjs/loader:960:12) {
8:42:18 AM: code: 'URL_INVALID',
8:42:18 AM: [cause]: undefined
8:42:18 AM: }
8:42:18 AM: ​
8:42:18 AM: build.command failed
8:42:18 AM: ────────────────────────────────────────────────────────────────
8:42:18 AM: ​
8:42:18 AM: Error message
8:42:18 AM: Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
8:42:18 AM: ​
8:42:18 AM: Error location
8:42:18 AM: In build.command from netlify.toml:
8:42:18 AM: npm run build
8:42:18 AM: ​
8:42:18 AM: Resolved config
8:42:18 AM: build:
8:42:18 AM: command: npm run build
8:42:18 AM: commandOrigin: config
8:42:18 AM: environment:
8:42:18 AM: - NEXT_PRIVATE_TARGET
8:42:18 AM: publish: /opt/build/repo/.next
8:42:18 AM: publishOrigin: config
8:42:18 AM: plugins:
8:42:18 AM: - inputs: {}
8:42:18 AM: origin: ui
8:42:18 AM: package: '@netlify/plugin-nextjs'
8:42:20 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:42:20 AM: Failing build: Failed to build site
8:42:20 AM: Finished processing build request in 1m9.026s

Airbnb style conflict?

Arrow functions are used for the TSX components in this boilerplate (e.g. Meta.tsx), but it is discouraged in Airbnb styles as shown below.

Could you please tell me why?

// bad
class Listing extends React.Component {
  render() {
    return <div>{this.props.hello}</div>;
  }
}

// bad (relying on function name inference is discouraged)
const Listing = ({ hello }) => (
  <div>{hello}</div>
);

// good
function Listing({ hello }) {
  return <div>{hello}</div>;
}

Source: https://stackoverflow.com/questions/37288950/why-does-the-airbnb-style-guide-say-that-relying-on-function-name-inference-is-d

Sign-up and Sign-in meta descriptions should be swapped

Sign-up description says "sign in"
Sign-in description says "create an account"

I think they should be swapped.

title: 'Sign up',
description:
'Seamlessly sign in to your account with our user-friendly login process.',
};

title: 'Sign in',
description:
'Effortlessly create an account through our intuitive sign-up process.',
};

Unresolved module when using absolute import

Here's my file structure (I've removed anything that isn't relevant).

- src
  - components
    - Some.tsx
  - pages
    - index.tsx 
- tsconfig.json

I want to import Some.tsx in my index.ts using absolute path. In my tsconfig.json, I have

{
  "compilerOptions": {
    "lib": ["dom", "dom.iterable", "esnext"],
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "removeComments": true,
    "preserveConstEnums": true,
    "strict": true,
    "alwaysStrict": true,
    "strictNullChecks": true,
    "noUncheckedIndexedAccess": true,

    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "allowUnreachableCode": false,
    "noFallthroughCasesInSwitch": true,

    "target": "es5",
    "outDir": "out",
    "declaration": true,
    "sourceMap": true,

    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "allowJs": false,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,

    "jsx": "preserve",
    "noEmit": true,
    "isolatedModules": true
  },
  "exclude": ["./out/**/*", "./node_modules/**/*"],
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],

  // absolute path
  "baseUrl": ".",
  "paths": {
    "@/components/*": ["src/components/*"]
  }
}

I import using this is my index.tsx

import Some from '@/components/Some';

and I got module not found error, but this

import Some from '../components/Some';

works fine.

Any idea why?

Use getLayout function to customize layout

As it's written on the official docs.

// pages/index.js

import Layout from '../components/layout'
import NestedLayout from '../components/nested-layout'

export default function Page() {
  return {
    /** Your content */
  }
}

Page.getLayout = function getLayout(page) {
  return (
    <Layout>
      <NestedLayout>{page}</NestedLayout>
    </Layout>
  )
}
// pages/_app.js

export default function MyApp({ Component, pageProps }) {
  // Use the layout defined at the page level, if available
  const getLayout = Component.getLayout || ((page) => page)

  return getLayout(<Component {...pageProps} />)
}

about the project templates folder confuse

Sorry, I'm new to nextjs. When I was learning this project, I found that there is a templates directory in the source code, and there is a Main.tsx file under it. What is this templates directory used for? What is this Main.tsx used for? Thank you for your dedication.

Deploy on Vercel

I've encountered an issue with the one-click deploy feature on Vercel. When I try to use it, I end up with an empty repository on my personal GitHub account. Below are the screenshots of the process:

Attempting One-Click Deploy

Screenshot 2023-07-07 at 23 07 50

Resulting Empty Repository

Screenshot 2023-07-07 at 23 02 21 Screenshot 2023-07-07 at 23 03 07

As a workaround, I tried copying the template to my git like so:

Copying Template to Git

Screenshot 2023-07-07 at 23 01 11

However, this results in the framework preset being set to "Other":

Framework Preset Set to Other

Screenshot 2023-07-07 at 23 10 43

According to the Vercel documentation, it's possible to override the Framework Preset for a specific deployment by adding a framework to the vercel.json configuration.

Should we add this file to the repository to resolve the issue? I would appreciate any guidance or assistance on this matter.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.