# AlloyJS WatchFace and Health Data

**URL:** <https://forum.repebble.com/t/alloyjs-watchface-and-health-data/424>\
**Category:** Watchapp/Face Developers Corner\
**Created:** [March 23, 2026, 8:44pm UTC](https://forum.repebble.com/t/alloyjs-watchface-and-health-data/424 "2026-03-23T20:44:58Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![cocoruby](https://avatars.discourse-cdn.com/v4/letter/c/3d9bf3/32.png) [@cocoruby](https://forum.repebble.com/u/cocoruby)\
**Post date:** [March 23, 2026, 8:44pm UTC](https://forum.repebble.com/t/alloyjs-watchface-and-health-data/424/1 "2026-03-23T20:44:58Z")

</div>

Hello all,

I am developping a watchface for Pebble Time 2 using Alloy framework.  
I am trying to display a step counter but cannot find how to access health Data with Javascript framework.

I only find documentation about C code.

Is there a way to get the step count in an Alloy watchface ?

Thank you in advance for your answers.

Regards.

Nicolas.

---

<div class="post-metadata">

**Author:** ![eric](https://yyz1.discourse-cdn.com/flex033/user_avatar/forum.repebble.com/eric/32/239_2.png) [@eric](https://forum.repebble.com/u/eric)\
**Post date:** [March 23, 2026, 11:20pm UTC](https://forum.repebble.com/t/alloyjs-watchface-and-health-data/424/2 "2026-03-23T23:20:13Z")

</div>

Good question! @jpx I might have some tips on how to call C functions from inside an Alloy app.

---

<div class="post-metadata">

**Author:** ![jpx](https://yyz1.discourse-cdn.com/flex033/user_avatar/forum.repebble.com/jpx/32/9_2.png) [@jpx](https://forum.repebble.com/u/jpx)\
**Post date:** [March 24, 2026, 6:35pm UTC](https://forum.repebble.com/t/alloyjs-watchface-and-health-data/424/3 "2026-03-24T18:35:57Z")

</div>

unfortunately I do not, sorry!

---

<div class="post-metadata">

**Author:** ![cocoruby](https://avatars.discourse-cdn.com/v4/letter/c/3d9bf3/32.png) [@cocoruby](https://forum.repebble.com/u/cocoruby)\
**Post date:** [March 24, 2026, 8:40pm UTC](https://forum.repebble.com/t/alloyjs-watchface-and-health-data/424/4 "2026-03-24T20:40:58Z")

</div>

Hello,

No problem. I am still looking for documentation.

I found this page : [Moddable | Documentation | XS | XS in C](https://www.moddable.com/documentation/xs/XS%20in%20C)

But I don’t really know what to do with that 😅.

Regards.

Nicolas

---

<div class="post-metadata">

**Author:** ![stc1988](https://yyz1.discourse-cdn.com/flex033/user_avatar/forum.repebble.com/stc1988/32/322_2.png) [@stc1988](https://forum.repebble.com/u/stc1988)\
**Post date:** [March 25, 2026, 2:55am UTC](https://forum.repebble.com/t/alloyjs-watchface-and-health-data/424/5 "2026-03-25T02:55:09Z")

</div>

In conclusion, developers cannot use C code in Alloy app.

Because Alloy app implements this through a feature called [mods](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/xs/mods.md), it cannot include native C code.  
If you want to add an API that executes C code, you need to add a JavaScript API using XS in C to the host application on the PebbleOS side.

---

<div class="post-metadata">

**Author:** ![cocoruby](https://avatars.discourse-cdn.com/v4/letter/c/3d9bf3/32.png) [@cocoruby](https://forum.repebble.com/u/cocoruby)\
**Post date:** [March 25, 2026, 6:46am UTC](https://forum.repebble.com/t/alloyjs-watchface-and-health-data/424/6 "2026-03-25T06:46:16Z")

</div>

OK,

If I understand well I can use XS in C to create a bridge between JavaScript and C code.

And I can do and build all of this in the same project.

Is that so ?

Regards,

Nicolas

---

<div class="post-metadata">

**Author:** ![cocoruby](https://avatars.discourse-cdn.com/v4/letter/c/3d9bf3/32.png) [@cocoruby](https://forum.repebble.com/u/cocoruby)\
**Post date:** [March 25, 2026, 6:54am UTC](https://forum.repebble.com/t/alloyjs-watchface-and-health-data/424/7 "2026-03-25T06:54:16Z")

</div>

I definitely have to take the time to read that documentation.

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![cr0ybot](https://yyz1.discourse-cdn.com/flex033/user_avatar/forum.repebble.com/cr0ybot/32/420_2.png) [@cr0ybot](https://forum.repebble.com/u/cr0ybot)\
**Post date:** [May 4, 2026, 5:48pm UTC](https://forum.repebble.com/t/alloyjs-watchface-and-health-data/424/8 "2026-05-04T17:48:01Z")

</div>

I haven’t tried it yet, but I’ve been eyeing this section of the Moddable docs about the [JavaScript `@` language syntax extension](https://moddable.com/documentation/xs/XS%20in%20C#syntax-extension) and the [`Native` API](https://moddable.com/documentation/xs/XS%20in%20C#native). However I’m unsure if the Pebble APIs for heath etc. are even available when building an Alloy project. Since there is _some_ C involved (`mdbl.c`) I’m assuming more C code could be added as well. I’ve personally been struggling a bit with memory limits/allocation with Alloy and am considering making an attempt to translate some things to C (in which I have very little experience).

---

<div class="post-metadata">

**Author:** ![cr0ybot](https://yyz1.discourse-cdn.com/flex033/user_avatar/forum.repebble.com/cr0ybot/32/420_2.png) [@cr0ybot](https://forum.repebble.com/u/cr0ybot)\
**Post date:** [May 4, 2026, 9:05pm UTC](https://forum.repebble.com/t/alloyjs-watchface-and-health-data/424/9 "2026-05-04T21:05:42Z")

</div>

No luck so far. The build fails with the `@`, and while the `Native` API doesn’t fail at build time, it definitely doesn’t work without some monkeying with how the app is compiled I imagine. I even tried something like this Moddable [XS in C example](https://github.com/Moddable-OpenSource/moddable/tree/5516726818906190d3a042d8be90219ce9d51b45/examples/js/xs-in-c) but couldn’t make it work.

---

<div class="post-metadata">

**Author:** ![cr0ybot](https://yyz1.discourse-cdn.com/flex033/user_avatar/forum.repebble.com/cr0ybot/32/420_2.png) [@cr0ybot](https://forum.repebble.com/u/cr0ybot)\
**Post date:** [May 5, 2026, 2:47pm UTC](https://forum.repebble.com/t/alloyjs-watchface-and-health-data/424/10 "2026-05-05T14:47:53Z")

</div>

# Hey folks, **I have found a way!**

 ![screenshot](https://canada1.discourse-cdn.com/flex033/uploads/pebble1/original/1X/025469572c996e20961394757769920b573b6e2b.png)

None of the XS-in-C stuff works right now, but there is another path: _PKJS messages_.

I confirmed that Pebble C APIs are accessible from `mdbl.c` and was able to set up a PKJS relay for the information I want to display (steps and BPM). I’ve created a minimal Alloy watchface repo that I hope others will find useful:

> **[GitHub - cr0ybot/pebble-c-pkjs-alloy-relay: Demonstration using PKJS to relay messages between...](https://github.com/cr0ybot/pebble-c-pkjs-alloy-relay/)**
>
> Demonstration using PKJS to relay messages between C and Alloy

The `health_relay` module should be portable enough to copy/paste into any project as long as you wire it up in `main()` and also copy the PKJS `appmessage` listener. Oh, and don’t forget to add the `health` capability in `package.json`!

Of course, having to relay this data via the phone isn’t ideal, but it’s a start until more robust Alloy-compatible APIs are available.

---

<div class="post-metadata">

**Author:** ![NoahK](https://avatars.discourse-cdn.com/v4/letter/n/bc79bd/32.png) [@NoahK](https://forum.repebble.com/u/NoahK)\
**Post date:** [May 5, 2026, 3:39pm UTC](https://forum.repebble.com/t/alloyjs-watchface-and-health-data/424/11 "2026-05-05T15:39:48Z")

</div>

Clever workaround, looking good!  
Definitely not ideal to have to go out and back to the phone. Hopefully the Alloy API gets these features soon.

---

<div class="post-metadata">

**Author:** ![stc1988](https://yyz1.discourse-cdn.com/flex033/user_avatar/forum.repebble.com/stc1988/32/322_2.png) [@stc1988](https://forum.repebble.com/u/stc1988)\
**Post date:** [May 5, 2026, 3:48pm UTC](https://forum.repebble.com/t/alloyjs-watchface-and-health-data/424/12 "2026-05-05T15:48:04Z")

</div>

> No luck so far. The build fails with the `@`, and while the `Native` API doesn’t fail at build time, it definitely doesn’t work without some monkeying with how the app is compiled I imagine

As I mentioned [before](https://forum.repebble.com/t/alloyjs-watchface-and-health-data/424/5), Alloy doesn’t allow including native code via XS in C. I don’t fully understand exactly what `mdbl.c` does, but Alloy applications built with Moddable target the contents under `embeddedjs` directory.

Using PKJS messages seems like a reasonable workaround for now. It might already be planned, but it could be worth asking in [Moddable Discussions](https://github.com/Moddable-OpenSource/moddable/discussions) whether there are plans to implement an Alloy API.
