This is a template project to build an application using NextJS (Server Side ReactJS framework) and Fastify (HTTP Server Framework).
NextJS is configured as a fastify plugin, source code for NextJS (including
configuration files and type definitions) live inside of the src/client
directory.
Server source code (Fastify powered), lives inside of the src/server directory.
By default, every route will attempt to render a page โค defined under
src/client/pages (read on NextJS for more details) โค, unless such route
is under the api/ route.
Every api/ prefixed route will reach directly to Fastify's router and will be
handled as defined.
This behavior is configurable on the src/server/plugin/next.ts file.
You will need NodeJS v14.15.4 or greather installed to run this project.
- Install dependencies
yarn installThis command will download all required dependencies for your project.
- Run the development server
yarn run devSources will be built and the project will be served on http://localhost:3000/.
For production use you must build both client and server source into plain JavaScript.
A configuration for this come OOTB with the build:production npm script
will build both client and server sources separately and prepare a directory
with the files
- Execute
yarn run build:productionto generate./distdirectory - Execute
node ./dist/main.js
The following output should be printed in your terminal
$ node ./dist/main.js
> event - compiled successfully
Every kind of contribution to this project is welcome, please, don't hesitate to open a Pull Request or Issue. I will be happy to help!
