{"id":13532887,"url":"https://github.com/saraelsa/msal-community-solid","last_synced_at":"2025-04-01T21:31:21.025Z","repository":{"id":92307641,"uuid":"607782907","full_name":"saraelsa/msal-community-solid","owner":"saraelsa","description":"A Solid.js SPA library for the Microsoft Identity Platform implemented as a wrapper around @azure/msal-browser.","archived":false,"fork":false,"pushed_at":"2023-07-25T12:46:33.000Z","size":122,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-12T03:14:20.297Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/saraelsa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-02-28T17:04:26.000Z","updated_at":"2023-05-19T16:13:47.000Z","dependencies_parsed_at":"2024-06-06T05:42:13.471Z","dependency_job_id":null,"html_url":"https://github.com/saraelsa/msal-community-solid","commit_stats":{"total_commits":17,"total_committers":2,"mean_commits":8.5,"dds":"0.11764705882352944","last_synced_commit":"dde4647868917b60e5370120e6fee84aa25c29d9"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saraelsa%2Fmsal-community-solid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saraelsa%2Fmsal-community-solid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saraelsa%2Fmsal-community-solid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saraelsa%2Fmsal-community-solid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saraelsa","download_url":"https://codeload.github.com/saraelsa/msal-community-solid/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246713074,"owners_count":20821836,"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":"2024-08-01T07:01:14.611Z","updated_at":"2025-04-01T21:31:16.017Z","avatar_url":"https://github.com/saraelsa.png","language":"TypeScript","funding_links":[],"categories":["📦 Components \u0026 Libraries"],"sub_categories":["Authentication \u0026 Authorization"],"readme":"# msal-community-solid\r\n\r\nThe msal-community-solid package provides an authentication solution for Solid.js single-page applications (SPAs) based on the Microsoft Identity Platform. The platform supports sign-in through Azure Active Directory, allowing sign-in with Microsoft accounts as well as Azure AD accounts; and Azure Active Directory B2C, which is a white-labeled and highly customizable authentication solution supporting local as well as social accounts.\r\n\r\n## Experimental Status\r\n\r\nThis package is currently experimental, meaning all APIs are subject to change. This is to simplify the process of improving the APIs based on community needs and feedback.\r\n\r\nSuggestions and feedback on this package are welcome and encouraged—please raise a GitHub issue to provide your input.\r\n\r\n\r\n## msal-browser\r\n\r\nThis package functions as a wrapper around the [msal-browser](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/master/lib/msal-browser) library, and the documentation for the library will apply here as well.\r\n\r\n## Basic Usage\r\n\r\n### Installation\r\n\r\nInstall the packages `msal-community-solid` and `@azure/msal-browser`.\r\n\r\n```bash\r\n# with pnpm\r\npnpm add msal-community-solid @azure/msal-browser\r\n```\r\n\r\n### MSAL Instance Setup\r\n\r\nCreate a `PublicClientApplication` (see the documentation for msal-browser for more details on how to do that):\r\n\r\n```ts\r\nimport { Configuration, IPublicClientApplication, PublicClientApplication } from \"@azure/msal-browser\";\r\n\r\nconst msalConfig: Configuration = {\r\n    auth: {\r\n        clientId: \"MY_CLIENT_ID\",\r\n        authority: \"https://login.microsoftonline.com/common/\",\r\n        redirectUri: \"https://my-application.example.com/\"\r\n    },\r\n    cache: {\r\n        cacheLocation: \"localStorage\"\r\n    }\r\n};\r\n\r\nconst msalInstance: IPublicClientApplication = new PublicClientApplication(msalConfig);\r\n```\r\n\r\nRefer to [the documentation for configuring msal-browser](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/configuration.md) to see how you can configure your application. In addition, refer to [msal-browser's documentation for working with Azure AD B2C](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/working-with-b2c.md) if you want to use Azure AD B2C.\r\n\r\nYou will need to register your app using the Azure Portal (or with an alternate way of accessing Azure such as the CLI).\r\n\r\n### MSAL Provider\r\n\r\nSet up the MSAL provider passing it the MSAL instance you created. All components that need reactive access to authentication state should be descendants of the MSAL provider.\r\n\r\n```tsx\r\nimport { MsalProvider } from \"msal-community-solid\";\r\n\r\nconst MyApp: Component = () =\u003e {\r\n    return (\r\n        \u003cMsalProvider instance={msalInstance}\u003e\r\n            \u003cMyChild /\u003e\r\n        \u003c/MsalProvider\u003e\r\n    );\r\n};\r\n```\r\n\r\nThe MSAL provider will handle initializing the MSAL instance. It will also handle incoming replies from OIDC/OAuth2 flows.\r\n\r\n### Usage\r\n\r\nWithin a child component of the provider, you can access the MSAL context with `useMsal`.\r\n\r\nIt returns a tuple composed of a read context and a write context.\r\n\r\nThe read context allows you to access MSAL's current interaction status, a list of all available accounts, and the currently active account. It is a Solid.js store, and you should follow the same rules as you would with other stores to avoid losing reactivity.\r\n\r\nThe write context allows you to access the actual MSAL instance and logger. Despite its name, you can still read from it—but keep in mind that reads here will not be reactive.\r\n\r\nYou can also use the `useIsAuthenticated` consumer to determine whether the user is authenticated or not, and the `AuthenticatedTemplate` and `UnauthenticateTemplate` components to conditionally display their children depending on user's authentication status.\r\n\r\n### Logging In, Out and Acquiring Tokens\r\n\r\nYou can directly use the MSAL instance (available in the write context returned by `useMsal`) to [log users in](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/login-user.md) and [out](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/logout.md), and to [acquire tokens](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/acquire-token.md).\r\n\r\n## Further Documentation\r\n\r\nThe public API of this library includes documentation comments which can be referred to for more information.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaraelsa%2Fmsal-community-solid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaraelsa%2Fmsal-community-solid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaraelsa%2Fmsal-community-solid/lists"}