{"id":15546734,"url":"https://github.com/joulev/custom-server-only-client-only","last_synced_at":"2026-06-10T11:31:55.430Z","repository":{"id":122688928,"uuid":"610668024","full_name":"joulev/custom-server-only-client-only","owner":"joulev","description":"A server-only and client-only alternative that allows you to customise the error message.","archived":false,"fork":false,"pushed_at":"2023-03-07T09:12:24.000Z","size":52,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-27T19:55:55.183Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/joulev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","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":"2023-03-07T08:37:32.000Z","updated_at":"2023-03-07T09:13:27.000Z","dependencies_parsed_at":"2023-05-30T03:15:14.231Z","dependency_job_id":null,"html_url":"https://github.com/joulev/custom-server-only-client-only","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"e7610025580974cf8be4f214de198bf8d7a7707f"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/joulev/custom-server-only-client-only","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joulev%2Fcustom-server-only-client-only","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joulev%2Fcustom-server-only-client-only/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joulev%2Fcustom-server-only-client-only/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joulev%2Fcustom-server-only-client-only/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joulev","download_url":"https://codeload.github.com/joulev/custom-server-only-client-only/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joulev%2Fcustom-server-only-client-only/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34151274,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-10-02T13:04:00.674Z","updated_at":"2026-06-10T11:31:55.408Z","avatar_url":"https://github.com/joulev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `custom-server-only` and `custom-client-only`\n\nThis package is a `server-only` and `client-only` alternative that library authors can use to customise the error message.\n\n## Why?\n\n`server-only` and `client-only` are great if you use it in your own apps. If it's imported in a third party library however, the error message is not so clear to debug anymore.\n\nFor example, say I make a library where a particular module must be client-only. If you use the module in a server environment, you get\n\n\u003e This module cannot be imported from a Server Component module. It should only be used from a Client Component.\n\nSince you didn't use `client-only` explicitly, you are left wondering what does \"this module\" refer to here.\n\nWith `custom-server-only` and `custom-client-only` here however, I can customise it to something like\n\n\u003e `\"my-package/use-window-size\"` cannot be used in a server component. Please use a client component instead. Refer to https://my-package.js.org/use-window-size for more info.\n\nwhich makes it easier for library users to debug.\n\n## Usage\n\n### `custom-server-only`\n\n```\nnpm install custom-server-only\n```\n\nBefore:\n\n```ts\nimport \"server-only\";\n```\n\nAfter:\n\n```ts\nimport ensureServer from \"custom-server-only\";\nensureServer(\"Error message here\");\n```\n\nIf you want to use the default error message instead, use `ensureServer()`. (But why don't you use `server-only` directly in that case?)\n\n### `custom-client-only`\n\n```\nnpm install custom-client-only\n```\n\nBefore:\n\n```ts\nimport \"client-only\";\n```\n\nAfter:\n\n```ts\nimport ensureClient from \"custom-client-only\";\nensureClient(\"Error message here\");\n```\n\nIf you want to use the default error message instead, use `ensureClient()`. You get the idea. (But why don't you use `client-only` directly in that case?)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoulev%2Fcustom-server-only-client-only","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoulev%2Fcustom-server-only-client-only","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoulev%2Fcustom-server-only-client-only/lists"}