{"id":39487283,"url":"https://github.com/vtex-apps/product-context","last_synced_at":"2026-01-18T05:28:21.142Z","repository":{"id":36797416,"uuid":"181966277","full_name":"vtex-apps/product-context","owner":"vtex-apps","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-26T00:00:33.000Z","size":381,"stargazers_count":8,"open_issues_count":7,"forks_count":12,"subscribers_count":39,"default_branch":"master","last_synced_at":"2025-07-26T07:17:44.180Z","etag":null,"topics":["hacktoberfest","store-framework","vtex-io"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vtex-apps.png","metadata":{"files":{"readme":"docs/README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-04-17T20:50:37.000Z","updated_at":"2025-04-09T20:35:58.000Z","dependencies_parsed_at":"2025-04-09T18:31:26.614Z","dependency_job_id":"d50f5f5c-9c91-4999-8b91-79f4c7172e32","html_url":"https://github.com/vtex-apps/product-context","commit_stats":null,"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"purl":"pkg:github/vtex-apps/product-context","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtex-apps%2Fproduct-context","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtex-apps%2Fproduct-context/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtex-apps%2Fproduct-context/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtex-apps%2Fproduct-context/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vtex-apps","download_url":"https://codeload.github.com/vtex-apps/product-context/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtex-apps%2Fproduct-context/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28530814,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"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":["hacktoberfest","store-framework","vtex-io"],"created_at":"2026-01-18T05:28:20.521Z","updated_at":"2026-01-18T05:28:21.128Z","avatar_url":"https://github.com/vtex-apps.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"📢 Use this project, [contribute](https://github.com/vtex-apps/product-context) to it or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n\n# Product Context\n\n\u003c!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --\u003e\n[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)\n\u003c!-- ALL-CONTRIBUTORS-BADGE:END --\u003e\n\nThe Product Context app is designed to provide essential product data to all child blocks within your store theme.\n\n## Configuration\n\n1. Add the `product-context` app as a dependency to your store theme's `manifest.json` file:\n    \n    ```diff manifest.json\n      \"dependencies\": {\n    +   \"vtex.product-context\": \"0.x\"\n      }\n    ```\n    \n2. Install the TypeScript types exported by the app by running the following command:\n    \n    ```sh\n    vtex setup\n    ```\n\nNow, you're ready to import components and hooks from the app. Check this example component that displays the product name using data stored in the nearest `ProductContext`:\n\n```tsx\n// Notice that this is TypeScript, and this code should be in a .tsx file\nimport React, { FC } from 'react'\nimport { useProduct } from 'vtex.product-context'\n\nconst MyComponent: FC = () =\u003e {\n  const productContextValue = useProduct();\n\n  return (\n    \u003cFragment\u003e\n      {productContextValue?.product?.productName}\n    \u003c/Fragment\u003e\n  )\n}\n\nexport default MyComponent\n```\n\n## Hooks\n\n### `useProduct`\n\nThe `useProduct` hook allows your app to retrieve data from the nearest `ProductContext` relative to its caller. Expect an object with the structure below as the return value:\n\n```ts\ninterface ProductContextState {\n  selectedItem?: Item | null\n  product: MaybeProduct\n  selectedQuantity: number\n  skuSelector: {\n    selectedImageVariationSKU: string | null\n    isVisible: boolean\n    areAllVariationsSelected: boolean\n  }\n  buyButton: BuyButtonContextState\n  assemblyOptions: {\n    items: Record\u003cGroupId, AssemblyOptionItem[]\u003e\n    inputValues: Record\u003cGroupId, InputValues\u003e\n    areGroupsValid: Record\u003cGroupId, boolean\u003e\n  }\n}\n```\n\n\u003e Note that if the hook is called outside a `ProductContextProvider`, the return value may be `undefined` or an empty object.\n\n### `useProductDispatch`\n\nThe `useProductDispatch` hook provides a `dispatch` function to manipulate the nearest `ProductContext`. The function supports the following actions:\n\n- `SELECT_IMAGE_VARIATION`: Sets the value for the `skuSelector.selectedImageVariationSKU` property.\n- `SET_QUANTITY`: Sets the value for the `selectedQuantity` property.\n- `SKU_SELECTOR_SET_VARIATIONS_SELECTED`: Sets the value for the `skuSelector.areAllVariationsSelected` property.\n- `SET_BUY_BUTTON_CLICKED`: Sets the value for the `buyButton.clicked` property.\n- `SKU_SELECTOR_SET_IS_VISIBLE`: Sets the value for the `skuSelector.isVisible` property.\n- `SET_SELECTED_ITEM`: Sets the value for the `selectedItem` property.\n- `SET_ASSEMBLY_OPTIONS`: Sets the value for the `assemblyOptions` property.\n- `SET_PRODUCT`: Sets the value for the `product` property.\n- `SET_LOADING_ITEM`: Sets the value of whether a selected item is loading.\n\n\u003c!-- DOCS-IGNORE:start --\u003e\n\n## Contributors ✨\n\nThanks goes to these wonderful people:\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/sahanljc\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/42151054?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eSahan Jayawardana\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/vtex-apps/product-context/commits?author=sahanljc\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n\u003c!-- DOCS-IGNORE:end --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvtex-apps%2Fproduct-context","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvtex-apps%2Fproduct-context","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvtex-apps%2Fproduct-context/lists"}