{"id":13493570,"url":"https://github.com/ryyppy/rescript-nextjs-template","last_synced_at":"2025-04-05T22:06:15.643Z","repository":{"id":37409706,"uuid":"189884199","full_name":"ryyppy/rescript-nextjs-template","owner":"ryyppy","description":"Opinionated Boilerplate for NextJS, Tailwind and ReScript","archived":false,"fork":false,"pushed_at":"2023-02-28T20:45:07.000Z","size":576,"stargazers_count":409,"open_issues_count":16,"forks_count":34,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-05T13:43:01.709Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://nextjs-default.ryyppy.now.sh","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryyppy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-02T19:03:01.000Z","updated_at":"2025-03-31T05:37:32.000Z","dependencies_parsed_at":"2024-07-31T21:24:54.491Z","dependency_job_id":null,"html_url":"https://github.com/ryyppy/rescript-nextjs-template","commit_stats":null,"previous_names":["ryyppy/nextjs-default"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryyppy%2Frescript-nextjs-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryyppy%2Frescript-nextjs-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryyppy%2Frescript-nextjs-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryyppy%2Frescript-nextjs-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryyppy","download_url":"https://codeload.github.com/ryyppy/rescript-nextjs-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406087,"owners_count":20933803,"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":[],"created_at":"2024-07-31T19:01:16.685Z","updated_at":"2025-04-05T22:06:15.603Z","avatar_url":"https://github.com/ryyppy.png","language":"JavaScript","readme":"# ReScript / NextJS Starter\n\nThis is a NextJS based template with following setup:\n\n- Full Tailwind v2 config \u0026 basic css scaffold (+ production setup w/ purge-css \u0026 cssnano)\n- [ReScript](https://rescript-lang.org) + React\n- Some ReScript Bindings for Next to get you started\n- Preconfigured Dependencies: `@rescript/react`\n\n**Note:** This setup is based on the `v1` `package-lock` format utilized by `npm@6`. If you want to use the newer `v2` version, delete the `package-lock.json` file and install the dependencies with `npm@7`.\n\n## Development\n\nRun ReScript in dev mode:\n\n```\nnpm run res:start\n```\n\nIn another tab, run the Next dev server:\n\n```\nnpm run dev\n```\n\n## Useful commands\n\nBuild CSS seperately via `postcss` (useful for debugging)\n\n```\n# Devmode\nnpx postcss styles/main.css -o test.css\n\n# Production\nNODE_ENV=production npx postcss styles/main.css -o test.css\n```\n\n## Test production setup with Next\n\n```\n# Make sure to uncomment the `target` attribute in `now.json` first, before you run this:\nnpm run build\nPORT=3001 npm start\n```\n\n## Tips\n\n### ES6 vs CommonJS\n\nThis template is complying to the ES6 module format, and therefore compiles ReScript code to `mjs` files. In case you want to use this template with the old `commonjs` format, do the following changes:\n\n1) Set `package-specs` and `suffix` to the following configuration:\n\n```json\n{\n  //...\n  \"package-specs\": {\n    \"module\": \"commonjs\",\n    \"in-source\": true\n  },\n  \"suffix\": \".bs.js\",\n}\n```\n\n2) Replace all import paths in `pages` that refer to `src/MyResFile.mjs` to `src/MyResFile.bs.js`\n\n```diff\n// pages/_app.js\n+import ResApp from \"src/App.mjs\"\n+import ResApp from \"src/App.bs.js\"\n```\n\nDone. You are now running on commonjs modules.\n\n### Don't be afraid to adapt your Next bindings\n\nWe ship some general bindings for `NextJS`, but we try to keep them simple. Some use-cases and APIs might not be reflected yet, so feel free to adapt the file as you see fit for your app.\n\nAs with every file fork, if you keep the changes git trackable, it's pretty straight-forward to pull in upstream changes later on.\n\n### Fast Refresh \u0026 ReScript\n\nMake sure to create interface files (`.resi`) for each `page/*.res` file.\n\nFast Refresh requires you to **only export React components**, and it's easy to unintenionally export other values that will disable Fast Refresh (you will see a message in the browser console whenever this happens).\n\nFor the 100% \"always-works-method\", we recommend putting your ReScript components in e.g. the `src` directory, and re-export them in plain `pages/*.js` files instead (check out the templates initial `pages` directory to see how we forward our React components to make sure we fulfill the Fast-Refresh naming conventions).\n\n### Filenames with special characters\n\nReScript supports filenames with special characters: e.g. `pages/blog/[slug].res`, but be aware that you can't access these these modules within other modules (since there is no syntax to express modules with e.g. `[` characters). Also don't forget to create an additional `.resi` file to comply to Fast Refresh rules.\n\n## Q \u0026 A\n\n### Why are the generated `.mjs` files tracked in git?\n\nIn ReScript, it's a good habit to keep track of the actual JS output the compiler emits. It allows quick sanity checking if we made any changes that actually have an impact on the resulting JS code (especially when doing major compiler upgrades, it's a good way to verify if production code will behave the same way as before the upgrade).\n\nThis will also make it easier for your Non-ReScript coworkers to read and understand the changes in Github PRs, and call you out when you are writing inefficient code.\n\nIf you want to opt-out, feel free to remove all compiled `.mjs` files within the `src` directory and add `src/**/*.mjs` in your `.gitignore`.\n\n### How trustworthy is this template?\n\nThis template was created through our learnings of building the [ReScript Documentation Platform](https://rescript-lang.org) (which is built in NextJS), and is maintained by one of the ReScript core team members. It irregularly receives updates depending on demand and urgency (e.g. important changes in the `Next.res` bindings, or package dependencies).\n","funding_links":[],"categories":["JavaScript","Nextjs Starter","ReScript"],"sub_categories":["Templates and Boilerplates"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryyppy%2Frescript-nextjs-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryyppy%2Frescript-nextjs-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryyppy%2Frescript-nextjs-template/lists"}