# solid-logic

> Core business logic of SolidOS

Latest version **5.0.0** (published 2026-08-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install solid-logic
pnpm add solid-logic
yarn add solid-logic
bun add solid-logic
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2026-08-19 |
| First published | 2020-10-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 2 |
| Unpacked size | 1.7 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 12 |
| Maintainers | timbl, bourgeoa, matthieubosquet, jeswr, timeaturdean, precious.oritsedere |

## Links

- npm: https://www.npmjs.com/package/solid-logic
- Repository: https://github.com/SolidOS/solid-logic
- Homepage: https://github.com/solidos/solid-logic#readme
- Issues: https://github.com/solidos/solid-logic/issues
- npm.io page: https://npm.io/package/solid-logic

## Dependencies (2)

- [solid-namespace](https://npm.io/package/solid-namespace.md) ^0.5.4
- [@uvdsl/solid-oidc-client-browser](https://npm.io/package/@uvdsl/solid-oidc-client-browser.md) ^0.2.3

## Recent versions

- 5.0.0 (latest) — 2026-08-19
- 6.0.0-2 (dev) — 2026-09-20
- 4.0.8-test.0 (test) — 2026-06-19
- 4.0.4-2a00cf2 (main) — 2026-03-18
- 4.0.4-880f6b7 (211-merge) — 2026-03-18
- 4.0.4-ce0bf33 (205-merge) — 2026-03-08
- 4.0.3-414b3f8 (195-merge) — 2026-02-15
- 4.0.2-7158c4e (190-merge) — 2026-02-05
- 4.0.2-62f9ee0 (189-merge) — 2026-02-05
- 4.0.2-e707fa6 (191-merge) — 2026-02-05
- 4.0.2-896492 (187-merge) — 2026-01-24
- 4.0.1-4523933 (186-merge) — 2026-01-23
- 4.0.1-bc10d6d (164-merge) — 2025-12-06
- 4.0.1-58e8410 (163-merge) — 2025-12-06
- 4.0.0-3818f4f (162-merge) — 2025-12-06
- … 411 more at https://npm.io/package/solid-logic/versions

## README

# solid-logic

<img src="https://raw.githubusercontent.com/solid/community-server/main/templates/images/solid.svg" alt="[Solid logo]" height="150" align="right"/>

[![MIT license](https://img.shields.io/github/license/solidos/solidos)](https://github.com/solidos/solidos/blob/main/LICENSE.md)


Core business logic of SolidOS which can be used for any webapp as well.


# Usage

## 📦 Install via npm

```sh
npm install solid-logic rdflib
```

> **Important**: `rdflib` is a peer dependency - you must install it separately.

### Import in your project (ESM/TypeScript)

```js
import { solidLogicSingleton, store, authn } from 'solid-logic';

// Example usage
console.log('Current user:', authn.currentUser());
```

## 🌐 Use directly in a browser

The UMD bundles externalize `rdflib` only.

The ESM bundles externalize both `rdflib` and the auth library packages `@uvdsl/solid-oidc-client-browser` / `@uvdsl/solid-oidc-client-browser/core`.

## Available Files

| Format | File | Usage | Global Variable |
|--------|------|-------|----------------|
| UMD | `dist/solid-logic.js` | Development | `window.SolidLogic` |
| UMD | `dist/solid-logic.min.js` | Production | `window.SolidLogic` |
| ESM | `dist/solid-logic.esm.js` | Development | Import only |
| ESM | `dist/solid-logic.esm.min.js` | Production | Import only |

### UMD Bundle (Script Tags)

**⚠️ Important**: Load rdflib **before** solid-logic or you'll get `$rdf is not defined` errors.

```html
<!-- 1. Load rdflib first (creates window.$rdf) -->
<script src="https://cdn.jsdelivr.net/npm/rdflib/dist/rdflib.min.js"></script>

<!-- 2. Load solid-logic (expects $rdf to exist) -->
<script src="https://unpkg.com/solid-logic/dist/solid-logic.min.js"></script>

<script>
	// Access via global variable
	const { solidLogicSingleton, store, authn } = window.SolidLogic;
	
	// Example usage
	console.log('Store:', store);
	console.log('Authentication:', authn.currentUser());
</script>
```

### ESM Bundle (Native Modules)

```html
<script type="module">
	import * as $rdf from 'https://esm.sh/rdflib';
	import { solidLogicSingleton, store, authn } from 'https://esm.sh/solid-logic@4.0.1';

	// Example usage
	console.log('Store:', store);
	console.log('Authentication:', authn.currentUser());
</script>
```

### ESM with Import Maps (Recommended)

```html
<script type="importmap">
{
	"imports": {
		"rdflib": "https://esm.sh/rdflib",
		"solid-logic": "https://esm.sh/solid-logic@4.0.1"
	}
}
</script>
<script type="module">
	import * as $rdf from 'rdflib';
	import { solidLogicSingleton, store, authn } from 'solid-logic';

	// Example usage - cleaner imports!
	console.log('Store:', store);
	console.log('Authentication:', authn.currentUser());
</script>
```

## Common Exports

```js
import { 
	solidLogicSingleton,  // Complete singleton instance
	store,                // RDF store
	authn,                // Authentication logic
	authSession,          // Authentication session
	ACL_LINK,            // ACL constants
	getSuggestedIssuers,  // Identity provider suggestions
	createTypeIndexLogic, // Type index functionality
	// Error classes
	UnauthorizedError,
	NotFoundError,
	FetchError
} from 'solid-logic';
```

# How to develop

Check the scripts in the `package.json` for build, watch, lint and test.

# Used stack

* TypeScript + Babel
* Jest
* ESLint
* Webpack

# How to release

Change version and push directly to main. This will trigger the npm release latest script in CI.

# History

Solid-logic was a move to separate business logic from UI functionality so that people using different UI frameworks could use logic code. 

It was created when the "chat with me" feature was built. We needed to share logic between chat-pane and profile-pane (which was part of solid-panes back then I think) due to that feature. The whole idea of it is to separate core solid logic from UI components, to make logic reusable, e.g. by other UI libraries or even non web apps like CLI tools etc.

---
_Source: https://npm.io/package/solid-logic · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
