Includes TypeScript, Material UI, ESLint, Jest, and React Testing Library
Choose how to start your development server based on your database configuration below.
Ensure you have a .env file with a DATABASE_URL variable set to file
DATABASE_URL="file:./dev.db"First time starting your app make sure to run prisma then start your app.
npm run prisma && npm run dev
If you're coming from running npx create-m2-app you should have a docker-compose.yml, and a Dockerfile.dev that will help you get your db up and running quickly.
Start up your postgres db:
docker-compose up
Then run prisma and start your development server
npm run prisma && npm run dev
npm run prisma will do a few things for us:
- Format your
prisma/schema.prismafile (prisma format) | prisma format documentation - Keeps your
prisma/schema.prismafile in sync with your database by auto generating migrations when needed (npm run migrate) | prisma migration documentation - Seed your database with (
npm run seed) | prisma seeding documentation
Prisma helps app developers build faster and make fewer errors with an open source ORM for PostgreSQL, MySQL and SQLite. | Source
Adding a table is as easy as adding a model to your schema.prisma file, followed by creating a migration. For a tutorial on this visit the prisma schema documentation.
Once you've made the appropriate changes to your schema.prisma file you can auto generate a migration using
npm run migrateThis will generate a new folder under prisma/migrations with a SQL file outlining the changes to be reflected to your database and also generate new TypeScript code for prisma client usage.
To learn more visit the prisma migration documentation or the prisma generate documentation.
To seed your database, using prisma client, add in sample data in the prisma/seed.ts file.
To learn more visit the prisma seeding documentation.
Using the prisma client you can do the various actions required to build applications utilizing a database.
To learn more visit working with the prisma client.
All scripts can be run by prefixing with npm run, for example npm run build
See the prisma generate documentation.
npm run generateSee the prisma migration documentation.
npm run migrateTo apply pending migrations to development, staging, or testing environments, run the
migrate deploycommand as part of your CI/CD pipeline | Source.
npm run deployWhen you want to reset your database to a clean slate, this clears all migrations and re-runs the migration list, then seeds the database. For more visit prisma migrate reset.
npm run resetRuns the prisma/seed.ts script to seed your database. See the prisma seeding documentation.
npm run seedAllows you to interact with and manage your data interactively. For more visit prisma studio.
npm run studioAn aggregate command used to format your schema file, check for differences from schema to db, generate a prisma client, and seed your database.
npm run prismaBuilds the production application in the .next folder.
npm run buildStarts the application in development mode with hot-code reloading, error reporting, and more:
The application will start at http://localhost:3000 by default. The default port can be changed with -p, like so:
npm run dev -p 4000Runs ESLint and Prettier auto-formatting.
npm run formatRuns ESLint static code analysis based on your .eslintrc configuration
npm run lintStarts the application in production mode. The application should be compiled with npm run build first.
The application will start at http://localhost:3000 by default. The default port can be changed with -p, like so:
npm run start -p 4000Runs Jest unit tests to validate changes between commits
npm run testRuns TypeScript compiler to validate there are no type errors between commits
npm run type-checkRuns type-check, lint, and test to make an better developer experience catching preventable quality errors.
npm run qualityRuns in development environment and logs accessibility error results in dev tools console. Tool implementation is in pages/_app.tsx.