Hows that possible? you may ask
Thing is - the nextJs is first of all, nodejs application, and node uses same javascript language for writing api and also for write views. Views can be html and also they can include javascript, and in case of nextJs - they also include react.
So, how to start use it?
All you need to do for starting a nextJs project is to write following command in your terminal:
npx create-next-app my-mynext-app
after installation finished, navigate to app folder and run
npm run dev
browse to http://localhost:3000 and see your app is runing now!The main advantage of nextJs framework is - SEO.
crawler can access pages more easily than at classic react app.
notice: you page already has react component:
export default function Home() {
return (
<div className={styles.container}>
<Head>
<title>Welcome</title>
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className={styles.main}>
<h1 className={styles.title} onClick={() => alert('hi')}>
Welcome!!!
</h1>
</main>
</div>
)
}
you can click on the title and see 'alert' appears