# Module Tutorial

**URL:** <https://forum.8thwall.com/t/module-tutorial/3631>\
**Category:** Technical Support\
**Tags:** general\
**Created:** [November 18, 2024, 4:26pm UTC](https://forum.8thwall.com/t/module-tutorial/3631 "2024-11-18T16:26:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peng\_Han\_Kum](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@Peng\_Han\_Kum](https://forum.8thwall.com/u/Peng_Han_Kum)\
**Post date:** [November 18, 2024, 4:26pm UTC](https://forum.8thwall.com/t/module-tutorial/3631/1 "2024-11-18T16:26:01Z")

</div>

Can someone give me a simple example such as:

Using the module to generate a random number.

I went through the backend function and I am still clueless…

---

<div class="post-metadata">

**Author:** ![GeorgeButler](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/georgebutler/32/1903_2.png) [@GeorgeButler](https://forum.8thwall.com/u/GeorgeButler)\
**Post date:** [November 18, 2024, 5:17pm UTC](https://forum.8thwall.com/t/module-tutorial/3631/2 "2024-11-18T17:17:54Z")

</div>

Backend functions are a component of modules but all modules don’t need backend functions. Backend functions are useful for things that you might want to do in a serverless environment away from the client side.

Modules are a way to re-use code, and work similarly to npm modules where you define your module and can then import it when creating your experience. Without backend functions your module code runs on the client which should be fine for a majority of use cases.

Here’s an example where the min and max values of the random generation are driven from config values on the module. Config values are editable for the developer using the module, not the end user.

```ts
// module.js is the main entry point for your 8th Wall module.
// Code here will execute before the project is loaded.

import {subscribe} from 'config'

let min = 0
let max = 1

subscribe((config) => {
  console.log('My Module Printed This!', config)

  min = config.min
  max = config.max
})

function generateRandomNumber() {
  return Math.random() * (max - min) + min
}

export {
  generateRandomNumber,
}

```

---

<div class="post-metadata">

**Author:** ![Peng\_Han\_Kum](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@Peng\_Han\_Kum](https://forum.8thwall.com/u/Peng_Han_Kum)\
**Post date:** [November 19, 2024, 2:20pm UTC](https://forum.8thwall.com/t/module-tutorial/3631/3 "2024-11-19T14:20:33Z")

</div>

![image](https://us1.discourse-cdn.com/flex019/uploads/x8thwall/original/2X/e/e83c1226da7c15eb6bc7666be7e54c9e55ff5740.png)

I followed the documentation and received this error.  
What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![GeorgeButler](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/georgebutler/32/1903_2.png) [@GeorgeButler](https://forum.8thwall.com/u/GeorgeButler)\
**Post date:** [November 19, 2024, 5:21pm UTC](https://forum.8thwall.com/t/module-tutorial/3631/4 "2024-11-19T17:21:59Z")

</div>

The entry path should point to the file containing your code. For instance, you can create a file named index.js (or any name you prefer) and set your backend’s entry path to ‘index.js’.

Take a look at the backend function template here:

[https://www.8thwall.com/8thwall/modules/bfn-studio/code/](https://www.8thwall.com/8thwall/modules/bfn-studio/code/)
