b0bgetout
b0bgetout

Reputation: 25

How can i start node script from my react-app?

What is the easiest way to launch a node.js script from a react-app by using a button?

I've a simple app with two buttons - using Material.io

export default function ButtonsMenu() {
    const classes = useStyles();

    return (
    <Grid>
        <Grid item xs={12}>
            <Paper style={styles.Paper}>
                <Button onClick={activeLights} variant="contained" color="primary" className={classes.button}>
                    ON
                </Button>
                <Button onClick={inactiveLights}variant="contained" color="secondary" className={classes.button}>
                    OFF
                </Button>
            </Paper>
        </Grid>
    </Grid>
    );

I also have an Arduino with led stripe that i wrote a node.js code for. How can i run it from the browser?

I know that i need a node server and a client, but need some help what should i do next.

I would appreciate any github repository etc.

Upvotes: 1

Views: 2468

Answers (1)

Mostafa AGUERRAM
Mostafa AGUERRAM

Reputation: 583

You can't do that, ReactJs is for fornt using, but instead make an API call to a node js server, even the browser will block you from calling local commands

Upvotes: 1

Related Questions