Can JS be visible in react and other frameworks?

Hi

While PHP script source code is not visible but in js frameorks any one can see the source code ? I found for example this code in react:

import React from 'react';

function Greeting(props) {
  return <h1>Hello, {props.name}!</h1>;
}

export default Greeting;

After transpile

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

function Greeting(props) {
  return React.createElement("h1", null, "Hello, ", props.name, "!");
}

var _default = Greeting;
exports.default = _default;

But this is still visible ?

Hi @GeorgesRemi, yes any frontend code is visible. In case of react it’s just the JSX syntax transpiled to plain JS that the browser understands; this may be a bit harder to read for humans, but it’s still perfectly comprehensible.

1 Like

Wouldn’t this be a security risk?

Which is why you dont put secure information on the front end. (other than to an already-authorized user, who is viewing secure information that they are authorized to view).

3 Likes