Start by setting up your local development environment.
For this tutorial, you need Node.js version 18+. To check your version of Node.js, run the following command in your terminal:
If you do not have Node.js installed, you can download it from nodejs.org (downloads).
Create a new project directory.
Navigate to the directory using the terminal.
create-next-app CLI tool.package.json file, enter the interactive initialization sequence. Run the following command in the terminal:Press enter to continue prompts.
To write a package.json file with default values, run npm init -y instead. Descriptive fields will be blank.
big-design, big-design-icons, big-design-theme, dotenv, next, react, react-dom, and styled-components.babel-plugin-styled-components is a supplement to the styled-components library that, among other things, offers improved debugging and minification of styles.
@types/node and @types/react contain TypeScript type definitions for Node.js and React.js respectively.
You can view a list of all the tested package versions in the package.json file on the Step 1 branch of this sample app’s repo.
Open package.json in your text editor.
Update the scripts property, by adding the dev, build, and start scripts.
Open package.json in your text editor.
Add an engines property with the following values:
In the root directory of your project, create a pages folder.
In the pages folder, create an index.tsx file. This is your app’s homepage.
Open index.tsx in your code editor.
Add Panel and Text BigDesign imports at the top of the file.
The Panel component allows you to contain content in a structured format. To learn more about the BigDesign’s Panel component, see Panel Developer Docs.
Text is one of the many predefined typography components in BigDesign. BigDesign offers multiple properties to customize the typographic palette. To view available typography components, see Typography.
Index functional component below the import statements. You can view index.tsx (GitHub).Next.js associates each file in the pages folder with a route based on the file’s name. Consequently, the Index React component you exported in pages/index.tsx will be accessible at /index.
Next.js allows you to use a theme provider and import CSS files from node_modules. In this tutorial, you integrate BigDesign React components to give your app a distinct BigCommerce look and feel.
Next.js uses the App component to initialize pages. To override the default App component, add the _app.tsx file to the pages folder. This is where you initialize BigDesign.
Open _app.tsx and import GlobalStyles from BigDesign and AppProps from Next.js.
Importing the GlobalStyles component will set BigCommerce’s base styles globally.
MyApp functional component below the import statements. You can view _app.tsx (GitHub).The Component prop represents the active page. Consequently, it will change when you navigate between routes.
Because BigDesign uses styled-components, we need to add additional configuration for both BigDesign and styled-components to function properly.
Add a custom _document.tsx file to your pages folder.
Import Document and DocumentContext, the built-in TypeScript types, from Next.js.
ServerStyleSheet from styled-components.Document class. You can view _document.tsx (GitHub).http://localhost:3000 from your browser. You should see the text “Hello world” displayed under Homepage.