<pre><code>{% js %}
    let admin_email = "{{ admin_email }}";
    console.log(admin_email);
    alert(admin_email);
{% endjs %}
</code></pre>

<p>Missed the <code>""</code> around the assignment. :)</p>

CC BY-SA 4.0
2020-06-16T09:10:10.567Z
2020-06-16T09:10:10.567Z
Rohan
<p>So I am trying to work with twig templates and I want to inject my project configuration in my js so I can use it.</p>

<p>I can do this</p>

<p><code>{% set admin_email = craft.app.projectConfig.get.email.fromEmail %}</code></p>

<p>And this gives me access to <code>{{ admin_email }}</code> anywhere in the document, just like <code>&lt;?php echo $admin_email ?&gt;</code> would do.</p>

<p>But I want to access these settings inside my JS as well. I have some tokens and other things stored inside there.</p>

<p>I tried doing this:</p>

<pre><code>{% js %}
    let admin_email = {{ admin_email }};
    console.log(admin_email);
    alert(admin_email);
{% endjs %}
</code></pre>

<p>But in vain. How do I get the settings inside my JS variables?</p>

CC BY-SA 4.0
2020-06-16T11:17:18.317Z
What's the reason you're getting the e-mail from projectConfig and not `craft.systemSettings.email.fromEmail`?
dmatthams
CC BY-SA 4.0
2020-06-16T11:19:41.470Z
It keeps giving me warning that is deprecated. This is the new way of getting it.
Rohan
CC BY-SA 4.0
2020-06-16T11:22:00.917Z
That's interesting, did not know that!
dmatthams
<plugin-development><craft3><php><settings>
How to get my craft projectConfig settings inside JS on the front end
# How to get my craft projectConfig settings inside JS on the front end

(Asked by: username_0 on 2020-06-16)

So I am trying to work with twig templates and I want to inject my project configuration in my js so I can use it.
I can do this
{% set admin_email = craft.app.projectConfig.get.email.fromEmail %}
And this gives me access to {{ admin_email }} anywhere in the document, just like  would do.
But I want to access these settings inside my JS as well. I have some tokens and other things stored inside there.
I tried doing this:
{% js %}
    let admin_email = {{ admin_email }};
    console.log(admin_email);
    alert(admin_email);
{% endjs %}

But in vain. How do I get the settings inside my JS variables?

**Tags:** plugin-development, craft3, php, settings

> **Comments:**
> **username_1**: What's the reason you're getting the e-mail from projectConfig and not `craft.systemSettings.email.fromEmail`?  
> **username_0**: It keeps giving me warning that is deprecated. This is the new way of getting it.  
> **username_1**: That's interesting, did not know that!  

---

## 1 answers

### Answer by username_0 on 2020-06-16. Score: 1 | Accepted answer

{% js %}
    let admin_email = "{{ admin_email }}";
    console.log(admin_email);
    alert(admin_email);
{% endjs %}

Missed the "" around the assignment. :)


---

