├── .gitignore ├── .prettierrc.js ├── README.md ├── package.json ├── pages ├── index.js └── songs │ └── [id].js ├── prisma ├── dev.db └── schema.prisma └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | .vercel 2 | .next 3 | node_modules 4 | .DS_Store -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | arrowParens: 'always', 3 | singleQuote: true, 4 | tabWidth: 2, 5 | trailingComma: 'none' 6 | }; 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Prisma + Next.js Starter 2 | 3 | Starter project for [Next.js + Prisma Tutorial](https://leerob.io/blog/next-prisma). 4 | 5 | See the completed example [here](https://github.com/leerob/next-prisma). 6 | 7 | ## Requirements 8 | 9 | - Node 10+ 10 | - Yarn (or NPM if you prefer) 11 | 12 | ## Getting Started 13 | 14 | After cloning the repository, you can run `yarn` to install the dependencies and then start the application with `yarn dev`. 15 | 16 | ```bash 17 | $ git clone https://github.com/leerob/next-prisma-starter.git 18 | $ yarn 19 | $ yarn dev 20 | ``` 21 | 22 | You are now able to view the application at http://localhost:3000. This starter uses fake data to begin the structure of the application. To verify it's working correctly, you should see: 23 | 24 | - `/` – The index route should show "Test Song" 25 | - `/songs/1` - The song page should show a hardcoded YouTube embed 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "prisma-next-starter", 3 | "description": "Starter project for Next.js + Prisma tutorial.", 4 | "version": "0.0.0", 5 | "author": { 6 | "name": "Lee Robinson", 7 | "email": "me@leerob.io", 8 | "url": "https://leerob.io" 9 | }, 10 | "license": "MIT", 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/leerob/prisma-next-starter.git" 14 | }, 15 | "engines": { 16 | "node": ">=10.0.0" 17 | }, 18 | "scripts": { 19 | "dev": "next", 20 | "build": "next build", 21 | "start": "next start", 22 | "db": "prisma studio --experimental", 23 | "db-save": "prisma migrate save --experimental", 24 | "db-up": "prisma migrate up --experimental", 25 | "generate": "prisma generate" 26 | }, 27 | "dependencies": { 28 | "@prisma/client": "2.1.1", 29 | "next": "9.4.4", 30 | "react": "16.13.1", 31 | "react-dom": "16.13.1" 32 | }, 33 | "devDependencies": { 34 | "@prisma/cli": "2.1.1" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /pages/index.js: -------------------------------------------------------------------------------- 1 | export async function getStaticProps() { 2 | return { 3 | props: { 4 | songs: [ 5 | { 6 | id: 1, 7 | name: 'Test Song' 8 | } 9 | ] 10 | } 11 | }; 12 | } 13 | 14 | export default ({ songs }) => ( 15 | 20 | ); 21 | -------------------------------------------------------------------------------- /pages/songs/[id].js: -------------------------------------------------------------------------------- 1 | export async function getStaticProps({ params }) { 2 | return { 3 | props: { 4 | song: { 5 | youtubeId: 'N6SQ9QoSjCI' 6 | } 7 | } 8 | }; 9 | } 10 | 11 | export async function getStaticPaths() { 12 | return { 13 | paths: [ 14 | { 15 | params: { 16 | id: '1' 17 | } 18 | } 19 | ], 20 | fallback: false 21 | }; 22 | } 23 | 24 | export default ({ song }) => ( 25 |