{"id":17099124,"url":"https://github.com/usmanbashir/godarkmode","last_synced_at":"2026-04-14T15:32:57.803Z","repository":{"id":57251753,"uuid":"430309960","full_name":"usmanbashir/godarkmode","owner":"usmanbashir","description":"A simple library for switching between Dark \u0026 Light mode on your website.","archived":false,"fork":false,"pushed_at":"2022-02-14T16:41:30.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-10T15:26:50.775Z","etag":null,"topics":["dark-mode","nextjs","plugin","tailwindcss"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/godarkmode","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/usmanbashir.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-21T08:17:14.000Z","updated_at":"2021-12-17T20:30:36.000Z","dependencies_parsed_at":"2022-09-04T23:10:07.180Z","dependency_job_id":null,"html_url":"https://github.com/usmanbashir/godarkmode","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/usmanbashir/godarkmode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usmanbashir%2Fgodarkmode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usmanbashir%2Fgodarkmode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usmanbashir%2Fgodarkmode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usmanbashir%2Fgodarkmode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/usmanbashir","download_url":"https://codeload.github.com/usmanbashir/godarkmode/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usmanbashir%2Fgodarkmode/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31803366,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T11:13:53.975Z","status":"ssl_error","status_checked_at":"2026-04-14T11:13:53.299Z","response_time":153,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["dark-mode","nextjs","plugin","tailwindcss"],"created_at":"2024-10-14T15:09:07.194Z","updated_at":"2026-04-14T15:32:57.787Z","avatar_url":"https://github.com/usmanbashir.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# goDarkMode\n\nA simple library for switching between Dark \u0026 Light mode on your website. It does this by managing the CSS class `dark` on your document element. **goDarkMode** is compatible with **TailwindCSS** and **Next.js**. But, you can also use it standalone in a vanilla JS project.\n\n## Installation\n\nUsing npm:\n\n```\n$ npm install godarkmode\n```\n\nUsing yarn:\n\n```\n$ yarn add godarkmode\n```\n\nUsing unpkg CDN:\n```\n\u003cscript src=\"https://unpkg.com/godarkmode/goDarkMode.js\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\n**goDarkMode** is pretty simple. There is nothing to configure and it only has a single\nmethod, `.goDarkMode`:\n\n```JavaScript\n// On a users first visit to the website, pick\n// a mode based on their default OS settings.\n//\n// On future visits, just pick their saved choice.\nconst mode = goDarkMode('auto') // =\u003e 'dark' || 'light'\n\n\n// For the website to use the dark mode either\n// based on your preference or the users pick\n// via the UI.\n//\n// You just need to specify the dark mode.\nconst mode = goDarkMode('dark') // =\u003e 'dark'\n\n\n// For the website to use the light mode either\n// based on your preference or the users pick\n// via the UI.\n//\n// You just need to specify the light mode.\nconst mode = goDarkMode('light') // =\u003e 'light'\n```\n\n## Usage with Next.js\n\nTo avoid the package from breaking your Next.js build as it is only meant to be used in a browser environment. You need to install the `next-transpile-modules` package and configure your `next.config.js` file accordingly.\n\n```JavaScript\n// next.config.js\n\nconst withTM = require('next-transpile-modules')(['godarkmode'])\n\nmodule.exports = withTM({\n  reactStrictMode: true,\n})\n```\n\nFollowed by wherever you are calling the `goDarkMode` method, make sure to check it is only called when running inside of a browser environment.\n\n```JavaScript\ntypeof window !== 'undefined' \u0026\u0026 goDarkMode('auto');\n```\n\n## Contributing\n\nEveryone is encouraged to help improve this project. Here are a few ways you can help:\n\n- [Report bugs](https://github.com/usmanbashir/godarkmode/issues)\n- Fix bugs and [submit pull requests](https://github.com/usmanbashir/godarkmode/pulls)\n- Write, clarify, or fix documentation\n- Suggest or add new features\n\n## Credit\n\n**goDarkMode** is made by [Usman Bashir](https://usmanbashir.com). Keep in touch with me by subscribing to [The Weekly Dispatch](https://twd.usm.io/) newsletter.\n\n## License\n\n[MIT](./LICENSE.txt)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusmanbashir%2Fgodarkmode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fusmanbashir%2Fgodarkmode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusmanbashir%2Fgodarkmode/lists"}