# What's the best way to store data with a plugin?

**URL:** https://meta.discourse.org/t/whats-the-best-way-to-store-data-with-a-plugin/388967
**Category:** Development
**Created:** [November 19, 2025, 7:27am UTC](https://meta.discourse.org/t/whats-the-best-way-to-store-data-with-a-plugin/388967 "2025-11-19T07:27:04Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Ethsim2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ethsim2/32/522255_2.png) [@Ethsim2](https://meta.discourse.org/u/Ethsim2)
#### Post date: [November 19, 2025, 8:04am UTC](https://meta.discourse.org/t/whats-the-best-way-to-store-data-with-a-plugin/388967/2 "2025-11-19T08:04:18Z")

</div>

If you only need to store a single Topic ID (like a configurable value), the simplest Discourse-native way is using a `SiteSetting`.  
You also get a built-in admin UI automatically.

`config/settings.yml`:

```yml
plugins:
  my_plugin_enabled:
    default: true
    client: false

  my_plugin_topic_id:
    default: 0
    client: false
    type: topic # gives you a topic selector in admin UI

```

In your Ruby plugin code:

```rb
topic_id = SiteSetting.my_plugin_topic_id
topic = Topic.find_by(id: topic_id)

```

If you prefer to store it programmatically (not exposed as a setting),  
`PluginStore` is also fine for a single key-value:

```rb
store = PluginStore.new("my_plugin")
store.set("topic_id", some_topic_id)

topic_id = store.get("topic_id")

```

---

_[View the full topic](https://meta.discourse.org/t/whats-the-best-way-to-store-data-with-a-plugin/388967)._
