{"id":38519790,"url":"https://github.com/gosling-lang/gosling-react-example","last_synced_at":"2026-01-17T06:37:43.699Z","repository":{"id":37185305,"uuid":"340522199","full_name":"gosling-lang/gosling-react-example","owner":"gosling-lang","description":"Template and examples for using Gosling.js and its API in React App","archived":false,"fork":false,"pushed_at":"2025-06-26T16:25:23.000Z","size":39491,"stargazers_count":10,"open_issues_count":1,"forks_count":16,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-23T12:24:44.123Z","etag":null,"topics":["hidivelab"],"latest_commit_sha":null,"homepage":"https://gosling-lang.github.io/gosling-react-example/.","language":"JavaScript","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/gosling-lang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2021-02-20T00:22:00.000Z","updated_at":"2025-06-26T16:25:25.000Z","dependencies_parsed_at":"2025-07-23T12:28:54.579Z","dependency_job_id":null,"html_url":"https://github.com/gosling-lang/gosling-react-example","commit_stats":null,"previous_names":["gosling-lang/gosling-react-template"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gosling-lang/gosling-react-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gosling-lang%2Fgosling-react-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gosling-lang%2Fgosling-react-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gosling-lang%2Fgosling-react-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gosling-lang%2Fgosling-react-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gosling-lang","download_url":"https://codeload.github.com/gosling-lang/gosling-react-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gosling-lang%2Fgosling-react-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28502678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T04:31:57.058Z","status":"ssl_error","status_checked_at":"2026-01-17T04:31:45.816Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["hidivelab"],"created_at":"2026-01-17T06:37:43.571Z","updated_at":"2026-01-17T06:37:43.684Z","avatar_url":"https://github.com/gosling-lang.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gosling React Example\n\nThis repository describes a way to use [Gosling.js](https://github.com/gosling-lang/gosling.js) along with [React](https://reactjs.org) and [Vite](https://vitejs.dev/).\n \nThe repository includes examples related to adding Gosling visualization to webpages and using Gosling JavaScript API functions (e.g., looking up clicked genomic region and its raw data, zooming to a certain gene of interest using a text input).\n\nAll examples can be found as separate files under a [src/example](/src/example/) folder.\n\nYou can find the online demo at https://gosling-lang.github.io/gosling-react-example/.\n\n## Using This Repository\n\nFork this repository, and then clone it.\n\n```sh\ngit clone https://github.com/[YOUR GITHUB ID]/gosling-react-example.git\ncd gosling-react-example\n```\n\nInstall all dependencies:\n\n```sh\npnpm install\n```\n\nRun the demo in your browser:\n\n```sh\npnpm start\n```\n\n## Using Gosling Component\n\nUse the Gosling.js's react component to visualize your data:\n\n```js\nimport { GoslingComponent } from \"gosling.js\";\n\nfunction App() {\n  return (\n    \u003cGoslingComponent\n      // Gosling specification\n      spec={{\n        \"tracks\": [{\n          \"data\": {\n            \"url\": \"https://server.gosling-lang.org/api/v1/tileset_info/?d=cistrome-multivec\",\n            \"type\": \"multivec\",\n            \"row\": \"sample\",\n            \"column\": \"position\",\n            \"value\": \"peak\",\n            \"categories\": [\"sample 1\"]\n          },\n          \"mark\": \"rect\",\n          \"x\": { \"field\": \"position\", \"type\": \"genomic\" },\n          \"color\": { \"field\": \"peak\", \"type\": \"quantitative\", \"legend\": true },\n          \"width\": 600,\n          \"height\": 130\n        }]\n      }}\n      // Styles of Gosling Component\n      margin={0}\n      padding={30}\n      border={'none'}\n      id={\"my-gosling-component-id\"}\n      className={\"my-gosling-component-style\"}\n      // Styling theme (refer to https://github.com/gosling-lang/gosling-theme)\n      theme={'light'}\n    /\u003e\n  );\n}\n```\n\n## Gosling API\n\nTo use the Gosling API, you need to create a [Ref](https://reactjs.org/docs/refs-and-the-dom.html) that stores a reference to the GoslingComponent.\n\n```javascript\nconst gosRef = React.useRef(null)\n\n\u003cGoslingComponent\n  ref = {gosRef}\n  spec = {/**your gosling spec**/}\n/\u003e\n\nif (gosRef.current) {\n  // then you can use any Gosling API you want\n  gosRef.current.api.exportPdf();\n}\n```\n\nBelow is an example\n```javascript\nimport React, { useRef, useEffect } from \"react\";\nimport { GoslingComponent} from 'gosling.js';\n\nfunction app(){\n  const gosRef = useRef(null);\n  \n  useEffect(() =\u003e {\n    if (gosRef.current) {\n      gosRef.current.api.subscribe('click', (type, eventData) =\u003e {\n            // print raw data that corresponds to the clicked mark\n            console.warn(type, eventData.data);\n      })\n    }\n    return ()=\u003e{\n      // remember to unsubscribe events\n      gosRef.current?.api.unsubscribe('click');\n    }\n  }, [gosRef.current]);\n\n  return (\n    \u003cdiv\u003e\n      \u003cGoslingComponent\n        ref = {gosRef}\n        spec = {/**your gosling spec**/}\n      /\u003e\n      \u003cbutton type=\"button\" onClick={() =\u003e gosRef.current?.api.exportPdf()}\u003e\n        Export PDF\n      \u003c/button\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\nPlease refer to [Gosling documentation](http://gosling-lang.org/docs/js-api) for a complete list of Gosling API.\n\n## Using Create React App\n\nInstall a react application using [Create React App](https://reactjs.org/docs/create-a-new-react-app.html#create-react-app).\n\n```\nnpx create-react-app my-app\ncd my-app\n```\n\nInstall `gosling.js` and its dependent libraries:\n\n```sh\nnpm add gosling.js higlass pixi.js\n```\n\nAdd the following stylesheet to `public/index.html`:\n```html\n\u003chead\u003e\n  \u003clink rel=\"stylesheet\" href=\"https://unpkg.com/higlass@[1.12]/dist/hglib.css\"\u003e\n\u003c/head\u003e\n```\n\n## Resource\n\n- Gosling Editor ([demo](https://gosling.js.org/), [code](https://github.com/gosling-lang/gosling.js)) is also based on `\u003cGoslingComponent/\u003e`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgosling-lang%2Fgosling-react-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgosling-lang%2Fgosling-react-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgosling-lang%2Fgosling-react-example/lists"}