{
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
}
}
Index.js
// pages/index.js
// Notice we do not need to import react or react-dom
export default () => {
return (<div>Hello JaxNode!</div>);
}
export async function getServerSideProps(context) {
return {
props: {}, // will be passed to the page component as props
}
}
export async function getStaticPaths() {
return {
paths: [
{ params: { ... } }
],
fallback: true // false or 'blocking'
};
}
export async function getStaticProps(context) {
return {
props: {}, // will be passed to the page component as props
}
}
import Link from 'next/link';
function Home() {
return (
<div>
Click{' '}
<Link href="/about">
<a>here</a>
</Link>{' '}
to read more
</div>
);
}
export default Home;
<Link as={`/p/${show.id}`}
href={`/post?id=${show.id}`}>
import Router from 'next/router';
function ReadMore() {
return (
<div>
Click <span onClick={() => Router.push('/about')}>here</span> to read more
</div>
);
}
export default ReadMore;
function HelloWorld() {
return (
<div>
Hello world
<p>scoped!</p>
<style jsx>{`
p {
color: blue;
}
div {
background: red;
}
@media (max-width: 600px) {
div {
background: blue;
}
}
`}</style>
<style global jsx>{`
body {
background: black;
}
`}</style>
</div>
);
}
export default HelloWorld;
model Project {
id Int @default(autoincrement()) @id
name String
tasks Task[]
}
model Task {
id Int @default(autoincrement()) @id
name String
project Project @relation(fields: [projectId], references: [id])
projectId Int
}
Prisma Schema Example
await db.project.findOne({ where: { id: data.id } })