# Topic ID as a variable?

**URL:** https://meta.discourse.org/t/topic-id-as-a-variable/374168
**Category:** Development
**Created:** [July 14, 2025, 6:48pm UTC](https://meta.discourse.org/t/topic-id-as-a-variable/374168 "2025-07-14T18:48:32Z")
**Posts on this page:** 1
**Showing post:** 15

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 25, 2025, 7:00pm UTC](https://meta.discourse.org/t/topic-id-as-a-variable/374168/15 "2025-09-25T19:00:05Z")

</div>

I created [GitHub - literatecomputing/discourse-custom-components · GitHub](https://github.com/literatecomputing/discourse-custom-components) as an example of how to do that.

> <https://github.com/literatecomputing/discourse-custom-components/blob/main/javascripts/discourse/api-initializers/custom-components.gjs#L13-L18>

Is a trivial example of inserting a component. So you would add some code before `<template>` to get the topic id and logic for whether to display.

I think you might want `topic-list-before-link` as the plugin outlet.

---

_[View the full topic](https://meta.discourse.org/t/topic-id-as-a-variable/374168)._
