{"id":13726027,"url":"https://github.com/mattermost/mattermost-redux","last_synced_at":"2025-05-07T21:30:51.458Z","repository":{"id":46243987,"uuid":"84744614","full_name":"mattermost/mattermost-redux","owner":"mattermost","description":"Redux for Mattermost","archived":true,"fork":false,"pushed_at":"2021-10-25T23:02:00.000Z","size":7994,"stargazers_count":197,"open_issues_count":9,"forks_count":386,"subscribers_count":49,"default_branch":"master","last_synced_at":"2025-04-28T05:49:12.341Z","etag":null,"topics":["hacktoberfest","mattermost","redux"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattermost.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2017-03-12T17:40:39.000Z","updated_at":"2025-04-04T13:36:20.000Z","dependencies_parsed_at":"2022-08-31T02:11:59.947Z","dependency_job_id":null,"html_url":"https://github.com/mattermost/mattermost-redux","commit_stats":null,"previous_names":[],"tags_count":376,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattermost%2Fmattermost-redux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattermost%2Fmattermost-redux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattermost%2Fmattermost-redux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattermost%2Fmattermost-redux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattermost","download_url":"https://codeload.github.com/mattermost/mattermost-redux/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252957089,"owners_count":21831434,"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":["hacktoberfest","mattermost","redux"],"created_at":"2024-08-03T01:02:48.865Z","updated_at":"2025-05-07T21:30:50.975Z","avatar_url":"https://github.com/mattermost.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","📦 Legacy \u0026 Inactive Projects"],"sub_categories":[],"readme":"## Mattermost Redux is now located at [mattermost/mattermost-webapp](https://github.com/mattermost/mattermost-webapp/tree/master/packages/mattermost-redux)\n\nThis repository is being left open for the time being while we set up proper monorepo infrastructure to be able to release mattermost-redux from there, but it will be archived once that has been set up.\n\nNew releases of mattermost-redux will be on hold while that is done, but feel free to continue using existing versions.\n\n---\n\n# Mattermost Redux ![CircleCI branch](https://img.shields.io/circleci/project/github/mattermost/mattermost-redux/master.svg)\n\nThe project purpose is consolidating the storage, web utilities and logic of the webapp and React Native mobile clients into a single driver. We encourage you to use mattermost-redux to power your own Mattermost clients or integrations.\n\n[Redux](http://redux.js.org/docs/introduction/) is the backbone for this project and many of the design decisions and patterns stem from it.\n\nMattermost is an open source Slack-alternative used by thousands of companies around the world in more than 16 languages. Learn more at https://mattermost.com.\n\n# Usage\n\n### Basic Usage\n\nTo hook up your application to the mattermost-redux store:\n\n```\nimport configureServiceStore from 'mattermost-redux/store';\n\nconfigureServiceStore(yourInitialState, yourAppReducers);\n\nconst store = configureStore();\n\n// use store\n```\n\n* `yourInitialState` - any initial state for any extra reducers you may have (set to `{}` if none)\n* `yourAppReducers` - any reducers from your app (set to `{}` if none)\n\n### Web Client Usage\n\nIf you're only looking to use the v4 JavaScript web client for the Mattermost server:\n\nWith async/await:\n```\nimport {Client4} from 'mattermost-redux/client';\n\nClient4.setUrl('https://your-mattermost-url.com');\n\nasync function loginAndGetUser(username, password) {\n    try {\n        await Client4.login(username, password);\n    } catch (error) {\n        console.error(error);\n        return null;\n    }\n\n    let user;\n    try {\n        user = await Client4.getMe();\n    } catch (error) {\n        console.error(error);\n        return null;\n    }\n\n    return user;\n}\n\n```\n\nWith promises:\n```\nimport {Client4} from 'mattermost-redux/client';\n\nClient4.setUrl('https://your-mattermost-url.com');\n\nfunction loginAndGetUser(username, password, callback) {\n    Client4\n        .login(username, password)\n        .then(Client4.getMe)\n        .then(callback)\n        .catch(console.error);\n}\n```\n\nIf you already have a [personal access token](https://docs.mattermost.com/guides/developer/personal-access-tokens.html) or session token, you can set the token manually instead of logging in:\n\n```\nimport {Client4} from 'mattermost-redux/client';\n\nClient4.setUrl('https://your-mattermost-url.com');\nClient4.setToken(yourToken);\n```\n\n### Browser Usage\n\nTo build a browser-compatible client via `webpack`:\n\n```\n$ git clone \u003cthis repo\u003e\n$ cd mattermost-redux\n$ make bundle\n```\n\nThis will generate `lib/mattermost.client4.js`, and `lib/mattermost.websocket.js` which can be loaded in a browser. Also note that `babel-polyfill` is required.\n\n```\n\u003cscript src=\"/path/to/babel/polyfill.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"/path/to/mattermost.client4.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"/path/to/mattermost.websocket.js\"\u003e\u003c/script\u003e\n\u003cscript type=\"text/javascript\"\u003e\n    const client = Mattermost.client4.default();\n    const wsClient = Mattermost.websocket.default;\n    var token;\n    client.setUrl('https://your-mattermost-url.com');\n    /* use an existing personal access token */\n    client.setToken('yourToken');\n    client.setIncludeCookies(false);\n    /* login and obtain a token */\n    client.login(username, password)\n    .then(function(user){\n        console.log(`Logged in as ${user.email}`);\n        token = client.getToken();\n    })\n    .then(function(){\n        wsClient.initialize(token, {}, {}, {connectionUrl: 'wss://your-mattermost-url.com/api/v4/websocket'});\n    })\n    .catch(function(err){\n        console.error(err);\n    });\n\u003c/script\u003e\n```\n\n### node.js Usage\n\nRunning the client from node.js requires making the `fetch` and `WebSocket` packages globally available, and the use of `babel-polyfill`:\n\n```\nrequire('babel-polyfill');\nrequire('isomorphic-fetch');\nif (!global.WebSocket) {\n    global.WebSocket = require('ws');\n}\nconst Client4 = require('./client/client4.js').default;\nconst client = new Client4;\nconst wsClient = require('./client/websocket_client.js').default;\nvar token;\n\nwsClient.setEventCallback(function(event){\n    console.log(event);\n});\n\nclient.setUrl('https://your-mattermost-url.com');\nclient.login(username, password)\n.then(function(me){\n    console.log(`logged in as ${me.email}`);\n    token = client.getToken();\n})\n.then(function(){\n    wsClient.initialize(token, {}, {}, {connectionUrl: 'wss://your-mattermost-url.com/api/v4/websocket'});\n})\n.catch(function(err){\n    console.error(err);\n});\n```\n\n# How to Contribute\n\n### How to Build mattermost-redux\n\nYou only need to build mattermost-redux if you are developing it.\n\n#### Webapp Development\nIf your mattermost-webapp and mattermost-redux are in the same directory, you only\nneed to run `npm run dev` or `npm run dev:watch`.\n\nIf you have mattermost-webapp in other directory or you are developing your own\napplication, you can define the environment variable `WEBAPP_DIR` to change the\ndestination app\n(e. g. `WEBAPP_DIR=/tmp/mattermost-webapp`).\n\n#### React Native (Mobile) Development\nIf your mattermost-mobile and mattermost-redux are in the same directory, you only\nneed to run `npm run dev-mobile` or `npm run dev-mobile:watch`.\n\nIf you have mattermost-mobile in other directory or you are developing your own\napplication, you can define the environment variable `MOBILE_DIR` to change the\ndestination app\n(e. g. `MOBILE_DIR=/tmp/mattermost-mobile`).\n\n#### Resetting apps to use package redux\nIf you want to go back to using the package specified redux in your web or mobile\napp you can stop the server and run `rm -rf .npminstall` to force\nyour project to reset to the specified package version on next server start.\n\n### Contribute Code\n\nIf you're contributing to help [migrate the webapp to Redux](https://docs.mattermost.com/developer/webapp-to-redux.html) go ahead and submit your PR. If you're just fixing a small bug or adding a small improvement then feel free to submit a PR for it. For everything else, please either work on an issue labeled `[Help Wanted]` or open an issue if there's something else that you'd like to work on.\n\nFeel free to drop by [the Redux channel](https://pre-release.mattermost.com/core/channels/redux) on our Mattermost instance.\n\n### Running the Tests\n\n`make test` will run the unit tests against a mocked server.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattermost%2Fmattermost-redux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattermost%2Fmattermost-redux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattermost%2Fmattermost-redux/lists"}