{"id":29150156,"url":"https://github.com/humanmade/repress","last_synced_at":"2025-06-30T23:09:45.130Z","repository":{"id":55441258,"uuid":"120388807","full_name":"humanmade/repress","owner":"humanmade","description":"Connect your Redux store to the WordPress REST API.","archived":false,"fork":false,"pushed_at":"2020-12-30T19:30:40.000Z","size":96,"stargazers_count":82,"open_issues_count":9,"forks_count":11,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-06-30T16:14:53.836Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/humanmade.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}},"created_at":"2018-02-06T02:13:02.000Z","updated_at":"2025-04-23T16:37:46.000Z","dependencies_parsed_at":"2022-08-15T00:20:42.723Z","dependency_job_id":null,"html_url":"https://github.com/humanmade/repress","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/humanmade/repress","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanmade%2Frepress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanmade%2Frepress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanmade%2Frepress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanmade%2Frepress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/humanmade","download_url":"https://codeload.github.com/humanmade/repress/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanmade%2Frepress/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262864258,"owners_count":23376461,"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":"2025-06-30T23:09:44.185Z","updated_at":"2025-06-30T23:09:45.055Z","avatar_url":"https://github.com/humanmade.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ctable width=\"100%\"\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd align=\"left\" width=\"70%\"\u003e\n\t\t\t\u003cstrong\u003eRepress\u003c/strong\u003e\u003cbr /\u003e\n\t\t\tConnect your Redux store to the WordPress REST API.\n\t\t\u003c/td\u003e\n\t\t\u003ctd align=\"right\" width=\"20%\"\u003e\n\t\t\t\u003ca href=\"https://www.npmjs.com/package/@humanmade/repress\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@humanmade/repress.svg\" /\u003e\u003c/a\u003e\n\t\t\u003c/td\u003e\n\t\u003c/tr\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003e\n\t\t\tA \u003cstrong\u003e\u003ca href=\"https://hmn.md/\"\u003eHuman Made\u003c/a\u003e\u003c/strong\u003e project. Maintained by @rmccue.\n\t\t\u003c/td\u003e\n\t\t\u003ctd align=\"center\"\u003e\n\t\t\t\u003cimg src=\"https://hmn.md/content/themes/hmnmd/assets/images/hm-logo.svg\" width=\"100\" /\u003e\n\t\t\u003c/td\u003e\n\t\u003c/tr\u003e\n\u003c/table\u003e\n\nRepress is a tiny library which takes control of part of your Redux state and handles talking to the WordPress REST API. Repress only owns a piece of your Redux state (called the **substate**), allowing you to incrementally add it to existing projects and remain in control of your store.\n\nRepress requires Redux and [Redux Thunk](https://github.com/gaearon/redux-thunk).\n\nKeep reading for a simple introduction, or dive into [the documentation](docs/README.md).\n\n\n## Installation\n\nRepress is [available on npm](https://www.npmjs.com/package/@humanmade/repress), simply add it to your project to get started:\n\n```sh\nnpm install --save @humanmade/repress\n\n# Or, if you're using Yarn\nyarn add @humanmade/repress\n```\n\nYou'll then need to [connect it to your store](docs/start.md).\n\n\n## The Basics\n\nThis library is a reusable tool that you can gradually add to your codebase. You simply create \"handlers\" for every top-level object (posts or CPTs, comments, terms, and users) you'd like to keep in your Redux store, and the handler takes care of dispatching.\n\nThe handler \"owns\" a piece of your global Redux state called the **substate**, and handles dispatching and reducing any actions related to it. You can keep the substate wherever you want in your Redux store, allowing you to incrementally adopt the library.\n\nSetting up a handler is a three-step process:\n\n1. Instantiate a handler with options for the type\n2. Add the reducer to the store\n3. Create actions and helpers using the handler's methods\n\n\n### A Simple Example\n\nTypically, you'll want to have a single `types.js` file containing the setup for all your types. You can then use in your regular `actions.js` and `reducer.js` files used in Redux.\n\n```js\n// types.js\nimport { handler } from '@humanmade/repress';\n\nexport const posts = new handler( {\n\t// `type` (required): used to derive the action names, and typically should\n\t// match the object type (post type, taxonomy, etc).\n\ttype: 'posts',\n\n\t// `url` (required): base URL for the type.\n\turl:   window.wpApiSettings.url + 'wp/v2/posts',\n} );\n\n// Register any static archives up-front.\nposts.registerArchive( 'home', {} );\n```\n\n```js\n// reducer.js\nimport { combineReducers } from 'redux';\n\nimport { posts } from './types';\n\nexport default combineReducers( {\n\t// Any regular reducers you have go in here just like normal.\n\n\t// Then, create a substate for your handlers.\n\tposts: posts.reducer,\n} );\n```\n\nIn your connected components, you can use the higher-order components ([withSingle](docs/connecting.md) and [withArchive](docs/archives.md)) to pull out data from the substate easily:\n\n```js\n// Post.js\nimport { withSingle } from '@humanmade/repress';\nimport React from 'react';\n\nimport { posts } from './types';\n\nconst Post = props =\u003e \u003cdiv\u003e\n\t\u003ch1\u003e{ props.post.title.rendered }\u003c/h1\u003e\n\u003c/div\u003e;\n\nexport default withSingle(\n\t// Handler object:\n\tposts,\n\n\t// getSubstate() - returns the substate\n\tstate =\u003e state.posts,\n\n\t// mapPropsToId - resolve the props to the post ID\n\tprops =\u003e props.id\n)( Post );\n\n// Then just use \u003cPost id={ 42 } /\u003e !\n```\n\nAlternatively, implement it with hooks (requires react-redux 7.1+):\n\n```js\n// Post.js\nimport { useSingle } from '@humanmade/repress';\nimport React from 'react';\n\nimport { posts } from './types';\n\nconst Post = props =\u003e {\n\tconst postData = useSingle( posts, state =\u003e state.posts, props.id );\n\n\treturn (\n\t\t\u003cdiv\u003e\n\t\t\t\u003ch1\u003e{ postData.post.title.rendered }\u003c/h1\u003e\n\t\t\u003c/div\u003e\n\t);\n}\n```\n\n\n## About\n\nCopyright Human Made. Licensed under the [ISC License](LICENSE.md).\n\n## Credits\n\nCreated by Human Made to make building React apps with the WordPress REST API even easier. Repress is built using what we've learnt building and scaling React sites. [Hire us to work with you!](https://humanmade.com/)\n\nWritten and maintained by [Ryan McCue](https://github.com/rmccue).\n\nInterested in joining in on the fun? [Join us, and become human!](https://humanmade.com/hiring/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumanmade%2Frepress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhumanmade%2Frepress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumanmade%2Frepress/lists"}