├── .env.example
├── .gitignore
├── LICENSE
├── README.md
├── package-lock.json
├── package.json
├── public
├── favicon.ico
├── index.html
└── manifest.json
├── server
└── index.js
└── src
├── App.css
├── App.js
├── App.test.js
├── SMSForm.css
├── SMSForm.js
├── index.css
├── index.js
├── logo.svg
└── serviceWorker.js
/.env.example:
--------------------------------------------------------------------------------
1 | TWILIO_ACCOUNT_SID=
2 | TWILIO_AUTH_TOKEN=
3 | TWILIO_PHONE_NUMBER=
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 |
6 | # testing
7 | /coverage
8 |
9 | # production
10 | /build
11 |
12 | # misc
13 | .DS_Store
14 | .env
15 | .env.local
16 | .env.development.local
17 | .env.test.local
18 | .env.production.local
19 |
20 | npm-debug.log*
21 | yarn-debug.log*
22 | yarn-error.log*
23 |
24 | .eslintcache
25 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2018 Phil Nash
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Send SMS with React and Twilio
2 |
3 | This is an example of sending SMS using React and Twilio. It consists of a `SMSForm` component that communicates with a server endpoint to [send SMS messages via the Twilio REST API](https://www.twilio.com/docs/sms/send-messages).
4 |
5 | To see how to build the project yourself, check out the blog post [How to send an SMS from React with Twilio](https://www.twilio.com/blog/send-an-sms-react-twilio).
6 |
7 | This project was created from the [react-express-starter project](https://github.com/philnash/react-express-starter) and includes a React front end and an Express server.
8 |
9 | ## Running the project
10 |
11 | To run the project you will need a Twilio account and a Twilio phone number that can send SMS messages. Gather your Twilio Account Sid and Auth Token from the [Twilio console](https://www.twilio.com/console) and the phone number.
12 |
13 | Then, clone the project, change into the directory and install the dependencies.
14 |
15 | ```bash
16 | git clone https://github.com/philnash/send-sms-react-twilio.git
17 | cd send-sms-react-twilio
18 | npm install
19 | ```
20 |
21 | Copy the `.env.example` file to `.env` and fill in your Twilio credentials and phone number.
22 |
23 | Start the application on its own with the command:
24 |
25 | ```bash
26 | npm run dev
27 | ```
28 |
29 | Open the app at [localhost:3000](http://localhost:3000). You can now use the form to send SMS messages via your Twilio number.
30 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-express-starter",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "react": "^17.0.1",
7 | "react-dom": "^17.0.1",
8 | "react-scripts": "^5.0.1"
9 | },
10 | "scripts": {
11 | "start": "react-scripts start",
12 | "build": "react-scripts build",
13 | "test": "react-scripts test",
14 | "eject": "react-scripts eject",
15 | "server": "node-env-run server --exec nodemon | pino-colada",
16 | "dev": "run-p server start"
17 | },
18 | "proxy": "http://localhost:3001",
19 | "eslintConfig": {
20 | "extends": "react-app"
21 | },
22 | "browserslist": [
23 | ">0.2%",
24 | "not dead",
25 | "not ie <= 11",
26 | "not op_mini all"
27 | ],
28 | "devDependencies": {
29 | "body-parser": "^1.20.1",
30 | "express": "^4.18.2",
31 | "express-pino-logger": "^5.0.0",
32 | "node-env-run": "^4.0.2",
33 | "nodemon": "^2.0.20",
34 | "npm-run-all": "^4.1.5",
35 | "pino-colada": "^2.1.0",
36 | "twilio": "^3.83.3"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/philnash/send-sms-react-twilio/23e81b9d3788607f5a375c874d1e59810ec8214e/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |