#hello world

1 messages · Page 1 of 1 (latest)

empty capeBOT
#

Hi @lucid pelican. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

To create a simple "Hello World" application using Next.js, you can use the create-next-app CLI tool. This tool allows you to quickly start building a new Next.js application with everything set up for you. You can create a new app using the default Next.js template, or by using one of the official Next.js examples.

Here are the steps to create a new project interactively:

  1. Run one of the following commands in your terminal:
npx create-next-app@latest

or

yarn create next-app

or

pnpm create next-app

or

bunx create-next-app
  1. You will then be asked a series of prompts. Answer them according to your project requirements.

  2. Once you've answered the prompts, a new project will be created with the correct configuration depending on your answers.

After creating the project, you can create a simple "Hello World" function. Here's an example of how you can do it:

async function greeting(){
    console.log("Hello");
    console.log("Goodbye");
}

To run the development server, use the following command:

npm run dev

Your site will now be running at http://localhost:8000.

Sources:


Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@lucid pelican kapa.ai is still learning and improving, please let us know how it did by reacting below

lucid pelican
#

@empty cape I need to ask you, is it possible to target global styles from a css module?

empty capeBOT
#

Let me check the knowledge base for you. One moment! :books:

#

Yes, it is possible to target global styles from a CSS module in Next.js. However, the way you handle global styles depends on whether you're working within the pages directory or the app directory.

In the pages directory, global stylesheets are restricted to only pages/_app.js. For example, you can import a global stylesheet named styles.css into your pages/_app.js file like this:

import '../styles.css'
 
export default function MyApp({ Component, pageProps }) {
 return <Component {...pageProps} />
}

In the app directory, this restriction has been lifted. Global styles can be added to any layout, page, or component. For instance, you can import a global stylesheet named global.css into your app/layout.js file like this:

import './global.css'
 
export default function RootLayout({ children }) {
 return (
 <html lang="en">
 <body>{children}</body>
 </html>
 )
}

It's important to note that due to the global nature of stylesheets, and to avoid conflicts, you may only import them inside pages/_app.js or app/layout.js.

#

Sources:


Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: