{"id":22911492,"url":"https://github.com/domparty/nextjs-core","last_synced_at":"2026-05-10T09:33:13.469Z","repository":{"id":42283764,"uuid":"244427521","full_name":"domparty/nextjs-core","owner":"domparty","description":"A custom Next.JS implementation with some nice extra's","archived":false,"fork":false,"pushed_at":"2023-01-06T02:45:00.000Z","size":733,"stargazers_count":2,"open_issues_count":14,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-17T22:08:28.921Z","etag":null,"topics":["cli","core","graphql","nextjs","robots","sitemap"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/domparty.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-02T17:06:33.000Z","updated_at":"2020-04-16T11:19:24.000Z","dependencies_parsed_at":"2023-02-05T03:45:53.826Z","dependency_job_id":null,"html_url":"https://github.com/domparty/nextjs-core","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domparty%2Fnextjs-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domparty%2Fnextjs-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domparty%2Fnextjs-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domparty%2Fnextjs-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/domparty","download_url":"https://codeload.github.com/domparty/nextjs-core/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246628417,"owners_count":20808106,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","core","graphql","nextjs","robots","sitemap"],"created_at":"2024-12-14T04:17:01.317Z","updated_at":"2026-05-10T09:33:13.437Z","avatar_url":"https://github.com/domparty.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DOMParty Next.JS Core\n\nA custom Next.JS implementation with some nice extra's\n\n[![npm](https://img.shields.io/npm/v/@domparty/nextjs-core.svg)](https://www.npmjs.com/package/@domparty/nextjs-core) ![node](https://img.shields.io/node/v/@domparty/nextjs-core.svg) [![Tests](https://github.com/domparty/nextjs-core/workflows/Tests/badge.svg?branch=master)](https://github.com/domparty/nextjs-core/actions?query=workflow%3ATests)\n\n## Structure\n- Next.JS\n- Express.JS\n- GraphQL\n- GraphQL Playground\n- JSON Schema\n- Simple Node Logger\n- Sitemap\n\n## Why?\n\nEvery time you startup a new project you always end up making the same thing because you need them.\nFor example: a sitemap, robots.txt, api endpoints for frontend data, etc.\n\nThat's why we took Next.JS as our SSR base and implemented all sorts of useful stuff that you almost need in every project.\n\n## How to use it?\n\nSetting up the Core is simple and only requires 2 files, 2 folders and an npm install.\n\n- Run `npm i --save @domparty/nextjs-core react react-dom` inside your project\n- Create the following folder structure `src/pages`\n- Create the following file `src/server.js` with the following content:\n```javascript\nconst App = require('@domparty/nextjs-core');\nconst core = new App(__dirname, process.cwd());\ncore.init();\n```\n- Create the following file `src/pages/index.js` with the following content:\n```javascript\nimport React from 'react';\n\nfunction Home() {\n  return \u003cdiv\u003eHello World!\u003c/div\u003e;\n}\n\nexport default Home;\n```\n- Add the following script to your package.json:\n```\n\"start\": \"node ./src/server.js\"\n```\n- Run `npm start` and go to `http://localhost:5678/`\n\n## Example project?\nDon't want to set it up yourself? No problem we got you covered.\nBelow is a link to an example project that is ready to go:\n\nhttps://github.com/domparty/nextjs-core-example\n\n## What's in it?\n### Config\nBy default we include and expose an application config.\nBelow you will find the default value's for this config:\n```javascript\nconst baseConfig = {\n  application: {\n    name: '',\n    host: '0.0.0.0',\n    port: 5678,\n    dompartyHeaders: true\n  },\n  next: {\n    pagesDir: \"\"\n  },\n  logger: {\n    location: './log',\n    filename: 'app.log',\n    level: 'trace'\n  },\n  pwa: {\n    shortName: 'Project',\n    name: 'DOMParty Project',\n    version: 'v0.0.0',\n    backgroundColor: '#000000',\n    themeColor: '#000000'\n  },\n  cli: {\n    maxExecutionTimeout: 30,\n  },\n  graphql: {\n    enabled: true\n  },\n  robots: {\n    disallowAll: true,\n    disallowRules: []\n  },\n  sitemap: {\n    urls: []\n  }\n};\n```\n\nTo change or update the config you can do 2 things:\n1. Include a `config.json` in the following location: `$PROJECT_ROOT/config/config.json`\n2. Change the config after the construct of the core: `const core = new App(__dirname, process.cwd());` -\u003e `console.log(core.config)`\n\n### Logger\nAfter a `new` core has been constructed a global variable will be available that contains the logger.\n\nUsing the following functions you are able to log messages to the console and log file.\nDepending on the log level inside the config these messages will be printed to the console.\n```javascript\nglobal.log.trace('');\nglobal.log.debug('');\nglobal.log.info('');\nglobal.log.warn('');\nglobal.log.error('');\nglobal.log.fatal('');\n```\n\n#### Log Level\nThe application default log level is set to `trace`.\n\nYou can change the log level by adding the following block to your config file:\n```json\n{\n  \"logger\": {\n    \"level\": \"trace\"\n  }\n}\n```\n\n### CLI\nThe CLI can be used to run one-time jobs or to implement a cron-job.\nIf the app detects that an extra command line argument is given the CLI mode will be used and search for the task.\n\n```\nnode server.js exampleCommand\n```\n\nNew CLI tasks can be created in the tasks file that can be found in the root of your project.\nBelow you will find and example tasks.js:\n\n```javascript\nmodule.exports = {\n    exampleCommand: (core, args, completed) =\u003e {\n        console.log('Hello World from a task!');\n        completed();\n    }\n};\n```\n\n#### Max Execution Timeout\nTo make sure your CLI task won't be running forever we end tasks running longer then 30 seconds by default.\nThis can be changed by changing the config:\n\n```json\n{\n  \"cli\": {\n    \"maxExecutionTimeout\": 30\n  }\n}\n```\n\n### Express.JS\nThe web server running the whole show is Express.JS.\nThis allows for easy extending of custom routes, middlewares and much more.\n\nThe complete express instance and http connection are exposed after a core has been constructed and can be accessed like this:\n```javascript\nconst core = new App(__dirname, process.cwd());\nconst express = core.server;\nconst httpSession = core.http;\n```\n\nSome express functions to add middlewares and routes have been replicated to ensure they are pushed in the right place during the initialization.\nThese functions are available:\n```javascript\nconst core = new App(__dirname, process.cwd());\ncore.use((req, res, next) =\u003e {\n    console.log('Your middleware here');\n    next();\n});\n\ncore.get('/test', (req, res) =\u003e {\n    console.log('Route accessed!');\n    res.send('Hello');\n});\n\ncore.post('/test', (req, res) =\u003e {\n    console.log('Route accessed!');\n    res.send('Hello');\n});\n\ncore.put('/test', (req, res) =\u003e {\n    console.log('Route accessed!');\n    res.send('Hello');\n});\n\ncore.patch('/test', (req, res) =\u003e {\n    console.log('Route accessed!');\n    res.send('Hello');\n});\n\ncore.delete('/test', (req, res) =\u003e {\n    console.log('Route accessed!');\n    res.send('Hello');\n});\n```\n\n### Instant Listen (Next.JS)\nThe Next.JS compiler takes some time to boot up.\nThis is more noticeable in the dev version then the production build.\nBut to ensure that we are not waiting on Next.JS we implemented Instant Listen.\nThis means an alternative page (Loading Page) will be shown until Next.JS is ready to serve pages.\nNo need to reload this loading page since we are checking in the background if Next.JS is ready.\nAfter Next.JS is ready we will reload the page for you.\n\nSince we are not waiting on Next.JS this also means that routes for GraphQL and for example the Sitemap are instant ready to go and don't need to wait.\n\n### GraphQL\nComing soon...\n\n### PWA\nPWA's are the next generation app replacements.\nWe implemented the 2 required parts in our core to have your app PWA ready.\n\n#### manifest.json\nThe manifest is a file used to describe your application and can be updated by changing the config like this:\n```json\n{\n  \"pwa\": {\n    \"shortName\": \"Project\",\n    \"name\": \"DOMParty Project\",\n    \"version\": \"v0.0.0\",\n    \"backgroundColor\": \"#000000\",\n    \"themeColor\": \"#000000\"\n  }\n}\n```\n\n#### Service Worker\nA service worker is a script that your browser runs in the background, separate from a web page, opening the door to features that don't need a web page or user interaction.\nToday, they already include features like push notifications and background sync. In the future, service workers might support other things like periodic sync or geofencing.\nThe reason this is such an exciting API is that it allows you to support offline experiences, giving developers complete control over the experience.\n\nWe opted for a more static version of a service worker. Our service worker runs on `/sw.js` and does nothing.\nYeah you head it right nothing. No offline support, no caching, nothing. But why?\nWell to get your project ready for the time you are going to implement these things.\n\nRight now we only implemented a simple offline page. That means that when the service worker registers and a user is offline we show a basis you are offline page.\n\n### Robots.txt\nBy default we include a robots.txt for search engines to find the sitemap but also to disallow some routes.\nThis can be changed by updating the config. An example config can be found below:\n```json\n{\n  \"robots\": {\n    \"disallowAll\": false,\n    \"disallowRules\": [\n      \"/fonts\",\n      \"/api\",\n      \"/some/page/search/engines/dont/need/to/index\"\n    ]\n  }\n}\n```\n\n### Sitemap.xml\nBy default we include a sitemap.xml for search engines to index the site.\nThis sitemap can be updated by changing the config.\nAn example can be found here:\n```json\n{\n  \"sitemap\": {\n    \"urls\": [\n      {\n        \"url\": \"/page/1\",\n        \"changefreq\": \"daily\",\n        \"priority\": 0.3\n      },\n      {\n        \"url\": \"/page/2\",\n        \"changefreq\": \"daily\",\n        \"priority\": 0.6\n      }\n    ]\n  }\n}\n```\n\n### Using Preact\nComing soon...\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdomparty%2Fnextjs-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdomparty%2Fnextjs-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdomparty%2Fnextjs-core/lists"}