1556351125
Build a boilerplate BigCommerce app using Laravel on the back-end and React on the front-end to fast track your development process.
As Head of Product Strategy at BigCommerce, I often get to work with developers that are looking to quickly extend what our platform can do and enable a UI for merchants to interface with the new functionality they create. Something I’ve been wanting to offer those developers is a way to fast-track their concepts into a functional app on our platform — a boilerplate app using a popular BE and FE framework that is easily accessible.
While waiting for that problem to be magically solved, I had been prototyping a concept on my own time using some of our new Widget APIs, and realized out of necessity I had already created the foundation for a simple Laravel & React based app in the process.
This article documents those steps: what it took to get to a functional app using Laravel on the back-end and React on the front-end. Hopefully it fast-tracks your understanding of what it takes to quickly build your first BigCommerce app using approachable, modern frameworks. At the end, you’ll have a basic two-screen app (with BE and FE routing) you can run locally, which can be installed on a BigCommerce store and run API requests against it.
And yes, the link to GitHub with the final code is at the bottom.
Before jumping in, you’ll want to make sure you have installed the following dependencies on your dev machine:
To ease PHP development and enable the app you develop to be easily shared, you’ll want to use either Valet or Homestead, depending on your OS:
We’ll be using Valet for some of the steps below, but the functionality to host and share sites is similar across both Valet and Homestead. What’s more important in this tutorial is how to configure Laravel to use React and connect with BigCommerce.
This is where we will create a baseline for future development: a simple application that loads at a specific URL in your browser and loads a React component instead of the default Laravel screen.
Set up a directory to serve the app
We need to first set up a directory to store this and any future app you develop this way. You may have already run this during the Valet set-up process — in that case jump to the next step.
mkdir ~/Sites
cd ~/Sites
valet park
Create a new Laravel codebase
Use the Laravel command that creates the initial boilerplate for an app in the ~/Sites directory:
laravel new laravel-react-bigcommerce-app
You should see the command run its course, like this:
This command usually completes with a ‘Application ready! Build something amazing.’
Visit the app address to make sure it’s live locally
After the command above completes, you should be able to visit the following URL in your browser and see the default Laravel welcome screen:
http://laravel-react-bigcommerce-app.test
You should be looking at the Laravel welcome screen at this point.
Note: If you see It Works! instead, you’ll need to stop the Apache server running on localhost. See this Stack Overflow post for more details.
Make sure your app runs over HTTPS
As you can see by the ‘Not Secure’ that shows in the browser, the app by default will be served via HTTP. To serve via HTTPS instead, run the following command in the app directory:
valet secure
Now https://laravel-react-bigcommerce-app.test should work. If it doesn’t and you receive a connection refusal in the browser, try editing the Site.php Valet file as described here and rerunning valet secure (as noted in this GitHub issue comment).
Your app should now be served over HTTPS.
Set up React as the JS framework
By default Laravel comes pre-configured with Vue.js. We want to use React, so we’ll switch to it using the following command in your app root dir:
php artisan preset react
Now you are set up with React scaffolding in Laravel. However, you’ll still be getting the same Laravel welcome screen. We’ll fix that next.
Set up index page template to load the React app
The default page for a Laravel app is the welcome screen that’s in the welcome.blade.php file. We want to initialize React instead.
To do this, make the following changes:
<!DOCTYPE html>
<html>
<head>
@yield('title')
<meta name="csrf-token" content="{{csrf_token()}}" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="{{mix('/css/app.css')}}">
<script src="https://unpkg.com/react@16.6.3/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@16.6.3/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/moment@2.22.1/min/moment.min.js"></script>
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
</head>
<body>
<div id="root"></div>
<script type="text/javascript" src="{{mix('/js/app.js')}}"></script>
</body>
</html>
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('app');
});
Note that we’re including jQuery and Moment.js as dependancies as well, since they are extremely common needs when building out an app. They are not required for React to function.
Check Node.js version and install JS dependancies
For the initial JS compile and future steps, I was using Node v10.14.1. While it’s not required and you should be able to use new versions, I recommend using NVM or a similar library to help you manage your different Node versions easily. You can learn more about NVM and alternate managers here.
Now, install any dependancies your JS app needs by running this command your root app directory:
npm install
After a minute or two, you should have all the dependancies loaded.
Here’s an example of NVM being used to pick a specific Node version before installing dependancies.
Compile JS assets
Now that the dependancies are installed, you are ready to compile the JS assets into something that loads in the browser. Run:
npm run dev
You’ll notice you get a readout of how long certain assets took to compile and a notification from Laravel Mix when it’s done building.
Note that Mix is effectively a convenience wrapper around webpack, which can be confusing at first to understand. If you don’t already know about it, put webpack on your bucket list of research items. It’s a good tool to know how to wield within more complex projects.
Ok, let’s view https://laravel-react-bigcommerce-app.test/ now:
Wait… nothing is loading!?
Actually. React is, as you can see from the React DevTools being suggested. However, we don’t have any React components displaying.
Render your first React component
The Laravel React preset actually contains an example component that is already included in the initialization. By default it is looking for a DOM id that isn’t in the app.blade.php template.
To fix that, change the ‘example’ id references in /resources/js/components/example.js to ‘root’, which does exist as a DOM id in the template.
So this, at the bottom of that component file:
if (document.getElementById('example')) {
ReactDOM.render(<Example />, document.getElementById('example'));
}
Changes into this:
if (document.getElementById('root')) {
ReactDOM.render(<Example />, document.getElementById('root'));
}
After that change. Run the compile assets command again:
npm run dev
And when it’s complete, refresh you browser to see the component!
Our example React component loaded in the browser.
Note that this React component and others in this article are all using Bootstrap for layout and styling.
Now you are set up for React development with a Laravel back-end. However for a functional ecommerce app you’ll want two more pieces in place: routing and access to external data via an API. We’ll focus on routing first.
We’ll be using React Router for this. To install the dependency, run:
npm install --save react-router-dom
Once that is added, you are ready to implement routes within the app. Using the code below as a reference for changes needed, alter the following files:
Note that we’re including jQuery and Moment.js as dependancies as well, since they are extremely common needs when building out an app. They are not required for React to function.
Check Node.js version and install JS dependancies
For the initial JS compile and future steps, I was using Node v10.14.1. While it’s not required and you should be able to use new versions, I recommend using NVM or a similar library to help you manage your different Node versions easily. You can learn more about NVM and alternate managers here.
Now, install any dependancies your JS app needs by running this command your root app directory:
npm install
After a minute or two, you should have all the dependancies loaded.
Here’s an example of NVM being used to pick a specific Node version before installing dependancies.
Compile JS assets
Now that the dependancies are installed, you are ready to compile the JS assets into something that loads in the browser. Run:
npm run dev
You’ll notice you get a readout of how long certain assets took to compile and a notification from Laravel Mix when it’s done building.
Note that Mix is effectively a convenience wrapper around webpack, which can be confusing at first to understand. If you don’t already know about it, put webpack on your bucket list of research items. It’s a good tool to know how to wield within more complex projects.
Ok, let’s view https://laravel-react-bigcommerce-app.test/ now:
Wait… nothing is loading!?
Actually. React is, as you can see from the React DevTools being suggested. However, we don’t have any React components displaying.
Render your first React component
The Laravel React preset actually contains an example component that is already included in the initialization. By default it is looking for a DOM id that isn’t in the app.blade.php template.
To fix that, change the ‘example’ id references in /resources/js/components/example.js to ‘root’, which does exist as a DOM id in the template.
So this, at the bottom of that component file:
if (document.getElementById('example')) {
ReactDOM.render(<Example />, document.getElementById('example'));
}
Changes into this:
if (document.getElementById('root')) {
ReactDOM.render(<Example />, document.getElementById('root'));
}
After that change. Run the compile assets command again:
npm run dev
And when it’s complete, refresh you browser to see the component!
Our example React component loaded in the browser.
Note that this React component and others in this article are all using Bootstrap for layout and styling.
Step 2: Set up Basic App Routes
Now you are set up for React development with a Laravel back-end. However for a functional ecommerce app you’ll want two more pieces in place: routing and access to external data via an API. We’ll focus on routing first.
We’ll be using React Router for this. To install the dependency, run:
npm install --save react-router-dom
Once that is added, you are ready to implement routes within the app. Using the code below as a reference for changes needed, alter the following files:
/resources/js/app.js -> remove the example component require and instead require a new index.js file
/resources/js/screens/home.js -> new file that will render the home screen
/resources/js/index.js -> new file that will handle routing and render the nav
/resources/js/screens/list.js -> new file that will render the list screen
/routes/web.php -> update the back-end route that loads the main app to also load for the new ‘list’ route, which will enable the browser to load the right screen for https://laravel-react-bigcommerce-app.test/listregardless if it is navigated to directly (url) or indirectly (app link click)
import React, { Component } from 'react';
export default class Home extends Component {
render() {
return (
<div className="container">
<div className="row">
<div className="col-md-8">
<div className="card">
<div className="card-header">Home Page</div>
<div className="card-body">
This is the Home Page.
</div>
</div>
</div>
<div className="col-md-4">
<div className="card">
<div className="card-header">Side Bar</div>
<div className="card-body">
This is a Side Bar.
</div>
</div>
</div>
</div>
</div>
);
}
}
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter, Switch, Route, Link } from 'react-router-dom';
import Home from './screens/home';
import ListOfThings from './screens/list';
ReactDOM.render((
<BrowserRouter>
<div>
<nav className="container">
<ul className="nav mt-2 mb-2">
<li className="nav-item">
<Link className="nav-link" to="/">Home</Link>
</li>
<li className="nav-item">
<Link className="nav-link" to="/list">List</Link>
</li>
</ul>
</nav>
<Switch>
<Route exact path="/list" component={ ListOfThings } />
<Route component={ Home } />
</Switch>
</div>
</BrowserRouter>
), document.getElementById('root'));
import React from 'react';
export default class List extends React.Component {
render() {
return (
<div className="container">
<div className="row">
<div className="col-md-12">
<div className="card">
<div className="card-header">List Page</div>
<div className="card-body">
This is the List Page.
</div>
</div>
</div>
</div>
</div>
);
}
}
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/{url?}', function () {
return view('app');
})->where('','list');
After all those changes, run:
npm run dev
Reload your browser at https://laravel-react-bigcommerce-app.test and you’ll now see a functional layout for an app, including navigation, appear!
Looking more like an app, eh?
Alright, we have a good base now with React routing, so it’s time to start connecting the app to real data inside a BigCommerce store.
Create app in BC dev tools area
Head to devtools.bigcommerce.com and log in with your BigCommerce store account. Create an app and go to the ‘Technical’ step in them modal.
To start, you want at least the auth and load callback URLs to be set, since those are what BC will use to initiate the install process and enable the app to load within the BC control panel.
The callback URLs I used when developing.
After setting the callback URLs, you need to select which scopes your app will need. Keep track of this because your app will need to check the proper scopes have been granted when installed. If you were making a real app, you would only select what the app actually needs here, as BigCommerce will work to ensure you don’t have too many permissions.
The scopes I used when developing. Only select what you’ll actually use!
Save your app’s client ID and secret
The client ID and Secret are used to verify that your app requests are valid. Save these into environment variables within your app. In the sample Laravel app, we’re saving these in the .env file along with the scopes so each piece of app info is able to be set in one place.
Update your .env file (in the root app directory) to have the APP_URL set as https://laravel-react-bigcommerce-app.test and add new env variables at the bottom of the file for your BC App IDs and test API credentials for local dev.
# Existing env variable. Make sure it matches the base URL of your app
APP_URL=https://laravel-react-bigcommerce-app.test
[ ... other existing variables ... ]
# New env variables for BC app and a test API credentials for local dev
# The Client ID and Secret can be found at https://devtools.bigcommerce.com/my/apps by selecting 'View Client ID'
BC_APP_CLIENT_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
BC_APP_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# These local credentials can be created by creating an API Account within your BigCommerce store (Advanced Settings > API Accounts)
BC_LOCAL_CLIENT_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
BC_LOCAL_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
BC_LOCAL_ACCESS_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
BC_LOCAL_STORE_HASH=stores/xxxxxxxxxxx
Install Guzzle dependency
You can see above that there are calls to the BC API which are using Guzzle. To add that as a dependency, in the root of the development directory run:
composer require guzzlehttp/guzzle
Set up the install, load and BC API proxy routes
When the app is installed, it will look to the callbacks that are defined in the dev tools area.
Add the web routes below, so Laravel knows to route to the specific controller methods for each callback. We are implementing install and load here, to get the baseline experience working, however there are stubbed routes for future functionality like uninstall and remove-user too.
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/{url?}', function () {
return view('app');
})->where('', 'list');
Route::group(['prefix' => 'auth'], function () {
Route::get('install', 'MainController@install');
Route::get('load', 'MainController@load');
Route::get('uninstall', function () {
echo 'uninstall';
return app()->version();
});
Route::get('remove-user', function () {
echo 'remove-user';
return app()->version();
});
});
Route::any('/bc-api/{endpoint}', 'MainController@proxyBigCommerceAPIRequest')
->where('endpoint', 'v2\/.*|v3\/.*');
Create controller to handle app install and load requests, proxy BC API
You can see above that there are references to ‘MainController’. That is where we’ll put the logic that handles the OAuth handshake and stores the credentials generated for the store. Keep in mind this uses session based storage, so when the browser session expires, the app will stop working.
The last route is a proxy through to the BigCommerce v2 and v3 APIs. We’ll use that to enable a bc-api endpoint we can hit on the front-end, which helps us bypass CORs issues.
To power these routes, add the following MainController.php file into your /app/Http/Controllers directory:
<?php
namespace App\Http\Controllers;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Http\Request;
use GuzzleHttp\Psr7;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Client;
class MainController extends BaseController
{
protected $baseURL;
public function __construct()
{
$this->baseURL = env('APP_URL');
}
public function getAppClientId() {
if (env('APP_ENV') === 'local') {
return env('BC_LOCAL_CLIENT_ID');
} else {
return env('BC_APP_CLIENT_ID');
}
}
public function getAppSecret(Request $request) {
if (env('APP_ENV') === 'local') {
return env('BC_LOCAL_SECRET');
} else {
return env('BC_APP_SECRET');
}
}
public function getAccessToken(Request $request) {
if (env('APP_ENV') === 'local') {
return env('BC_LOCAL_ACCESS_TOKEN');
} else {
return $request->session()->get('access_token');
}
}
public function getStoreHash(Request $request) {
if (env('APP_ENV') === 'local') {
return env('BC_LOCAL_STORE_HASH');
} else {
return $request->session()->get('store_hash');
}
}
public function install(Request $request)
{
// Make sure all required query params have been passed
if (!$request->has('code') || !$request->has('scope') || !$request->has('context')) {
return redirect()->action('MainController@error')->with('error_message', 'Not enough information was passed to install this app.');
}
try {
$client = new Client();
$result = $client->request('POST', 'https://login.bigcommerce.com/oauth2/token', [
'json' => [
'client_id' => $this->getAppClientId(),
'client_secret' => $this->getAppSecret($request),
'redirect_uri' => $this->baseURL . '/auth/install',
'grant_type' => 'authorization_code',
'code' => $request->input('code'),
'scope' => $request->input('scope'),
'context' => $request->input('context'),
]
]);
$statusCode = $result->getStatusCode();
$data = json_decode($result->getBody(), true);
if ($statusCode == 200) {
$request->session()->put('store_hash', $data['context']);
$request->session()->put('access_token', $data['access_token']);
$request->session()->put('user_id', $data['user']['id']);
$request->session()->put('user_email', $data['user']['email']);
// If the merchant installed the app via an external link, redirect back to the
// BC installation success page for this app
if ($request->has('external_install')) {
return redirect('https://login.bigcommerce.com/app/' . $this->getAppClientId() . '/install/succeeded');
}
}
return redirect('/');
} catch (RequestException $e) {
$statusCode = $e->getResponse()->getStatusCode();
$errorMessage = "An error occurred.";
if ($e->hasResponse()) {
if ($statusCode != 500) {
$errorMessage = Psr7\str($e->getResponse());
}
}
// If the merchant installed the app via an external link, redirect back to the
// BC installation failure page for this app
if ($request->has('external_install')) {
return redirect('https://login.bigcommerce.com/app/' . $this->getAppClientId() . '/install/failed');
} else {
return redirect()->action('MainController@error')->with('error_message', $errorMessage);
}
}
}
public function load(Request $request)
{
$signedPayload = $request->input('signed_payload');
if (!empty($signedPayload)) {
$verifiedSignedRequestData = $this->verifySignedRequest($signedPayload, $request);
if ($verifiedSignedRequestData !== null) {
$request->session()->put('user_id', $verifiedSignedRequestData['user']['id']);
$request->session()->put('user_email', $verifiedSignedRequestData['user']['email']);
$request->session()->put('owner_id', $verifiedSignedRequestData['owner']['id']);
$request->session()->put('owner_email', $verifiedSignedRequestData['owner']['email']);
$request->session()->put('store_hash', $verifiedSignedRequestData['context']);
} else {
return redirect()->action('MainController@error')->with('error_message', 'The signed request from BigCommerce could not be validated.');
}
} else {
return redirect()->action('MainController@error')->with('error_message', 'The signed request from BigCommerce was empty.');
}
return redirect('/');
}
public function error(Request $request)
{
$errorMessage = "Internal Application Error";
if ($request->session()->has('error_message')) {
$errorMessage = $request->session()->get('error_message');
}
echo '<h4>An issue has occurred:</h4> <p>' . $errorMessage . '</p> <a href="'.$this->baseURL.'">Go back to home</a>';
}
private function verifySignedRequest($signedRequest, $appRequest)
{
list($encodedData, $encodedSignature) = explode('.', $signedRequest, 2);
// decode the data
$signature = base64_decode($encodedSignature);
$jsonStr = base64_decode($encodedData);
$data = json_decode($jsonStr, true);
// confirm the signature
$expectedSignature = hash_hmac('sha256', $jsonStr, $this->getAppSecret($appRequest), $raw = false);
if (!hash_equals($expectedSignature, $signature)) {
error_log('Bad signed request from BigCommerce!');
return null;
}
return $data;
}
public function makeBigCommerceAPIRequest(Request $request, $endpoint)
{
$requestConfig = [
'headers' => [
'X-Auth-Client' => $this->getAppClientId(),
'X-Auth-Token' => $this->getAccessToken($request),
'Content-Type' => 'application/json',
]
];
if ($request->method() === 'PUT') {
$requestConfig['body'] = $request->getContent();
}
$client = new Client();
$result = $client->request($request->method(), 'https://api.bigcommerce.com/' . $this->getStoreHash($request) . '/' . $endpoint, $requestConfig);
return $result;
}
public function proxyBigCommerceAPIRequest(Request $request, $endpoint)
{
if (strrpos($endpoint, 'v2') !== false) {
// For v2 endpoints, add a .json to the end of each endpoint, to normalize against the v3 API standards
$endpoint .= '.json';
}
$result = $this->makeBigCommerceAPIRequest($request, $endpoint);
return response($result->getBody(), $result->getStatusCode())->header('Content-Type', 'application/json');
}
}
**Major Note: **By default, your app is set to use your hardcoded API credentials in the .env file. When you install the app within BigCommerce, you want your app to use the credentials passed back during the OAuth token exchange. To do this, make sure your APP_ENV config value in your .env file is set to production, like so:
APP_ENV=production
Now, if you head to your BC store admin, to the **Apps -> My Apps -> My Draft Apps **section, you can install your app and see it successfully load inside the control panel.
Now the app is installable within BigCommerce.
Create a front-end experience that surfaces data in BigCommerce
All the pieces are in place to create front-end components that actually do something, so I created a simple set of React components and screens that:
The scopes that are required were:
To enable the front-end components to hit the API using the back-end BigCommerce API Proxy endpoints in MainController.php, add the following files to a new /resources/js/services/ directory:
export const ApiService = {
getOrders(params) {
params = Object.assign({
page: 1,
limit: 10,
}, params);
return axios({
method: 'get',
url: '/bc-api/v2/orders',
params,
});
},
updateOrder(orderId, data) {
return axios({
method: 'put',
url: `/bc-api/v2/orders/${orderId}`,
data,
});
},
deleteOrder(orderId) {
return axios({
method: 'delete',
url: `/bc-api/v2/orders/${orderId}`,
});
},
getResourceCollection(resource, params) {
params = Object.assign({
page: 1,
limit: 10,
}, params);
return axios({
method: 'get',
url: `/bc-api/${resource}`,
params,
});
},
getResourceEntry(resource, params) {
return axios({
method: 'get',
url: `/bc-api/${resource}`,
params,
});
},
updateResourceEntry(resource, data) {
return axios({
method: 'put',
url: `/bc-api/${resource}`,
data,
});
},
deleteResourceEntry(resource, data) {
return axios({
method: 'delete',
url: `/bc-api/${resource}`,
});
},
};
import {ApiService} from './ApiService';
export {
ApiService,
};
The actual components are nice and light. Which is the point, right? Three files handle this:
/resources/js/components/index.js
import {Spinner} from './Spinner';
import {Table} from './Table';
export {
Spinner,
Table,
};
/resources/js/components/Table/index.js
import React from 'react';
export class Table extends React.Component {
constructor(props) {
super(props);
}
getTableRow(data, index) {
return (
<tr key={index}>
{this.props.tableHeaders.map(function(header, index) {
let value = data;
if (header.index) {
value = data[header.index];
}
if (header.callback) {
value = header.callback(value);
}
return <td key={index}>{value}</td>
})}
</tr>
);
}
render() {
return (
<table className="table">
<thead className="table-thead">
<tr>{this.props.tableHeaders.map(function(header, index) {
return <td key={index}>{header.label}</td>;
})}</tr>
</thead>
<tbody className="table-tbody">
{this.props.tableData.map(this.getTableRow.bind(this))}
</tbody>
</table>
);
}
}
/resources/js/components/Spinner/index.js
import React from 'react';
export class Spinner extends React.Component {
render() {
return (
<div className="text-center">
<div className="spinner-border m-5" role="status">
<span className="sr-only">Loading...</span>
</div>
</div>
);
}
}
Now, with the API service and components in place, the screens can be updated to produce something functional. To bring it all together, change the following files:
resources/js/screens/home.js
import React from 'react';
import {Spinner} from '../components';
import {ApiService} from '../services/ApiService';
export default class Home extends React.Component {
constructor(props) {
super(props);
this.state = {
isCatalogSummaryLoading: true,
isStoreInfoLoading: true,
catalogSummary: {},
storeInfo: {},
};
}
componentWillMount() {
ApiService.getResourceEntry('v2/store').then(this.handleStoreInfoResponse.bind(this));
ApiService.getResourceEntry('v3/catalog/summary').then(this.handleCatalogSummaryResponse.bind(this));
}
handleStoreInfoResponse(response) {
this.setState({
isStoreInfoLoading: false,
storeInfo: response.data,
});
}
handleCatalogSummaryResponse(response) {
this.setState({
isCatalogSummaryLoading: false,
catalogSummary: response.data.data,
});
}
render() {
const fieldsInSummary = [
{
label: "Variant Count",
index: "variant_count",
format: "number",
},
{
label: "Inventory Count",
index: "variant_count",
format: "number",
},
{
label: "Inventory Value",
index: "inventory_value",
format: "currency",
},
];
return (
<div className="container">
<div className="row">
<div className="col-md-8">
<div className="card">
<div className="card-header">Home Page</div>
<div className="card-body">
{
(this.state.isStoreInfoLoading || this.state.isCatalogSummaryLoading)
?
<Spinner/>
:
<div className="row">
{fieldsInSummary.map(function(summaryItem, index) {
return <div className="col-12 col-lg-6 col-xl" key={index}>
<div className="card">
<div className="card-body">
<div className="row align-items-center">
<div className="col">
<h6 className="card-title text-uppercase text-muted mb-2">
{ summaryItem.label }
</h6>
<span className="h2 mb-0">
{
summaryItem.format === 'currency'
?
new Intl.NumberFormat(undefined, { style: 'currency', currency: this.state.storeInfo.currency }).format(this.state.catalogSummary[summaryItem.index])
:
this.state.catalogSummary[summaryItem.index]
}
</span>
</div>
</div>
</div>
</div>
</div>
}.bind(this))}
</div>
}
</div>
</div>
</div>
<div className="col-md-4">
<div className="card">
<div className="card-header">Side Bar</div>
<div className="card-body">
{
this.state.isStoreInfoLoading
?
<Spinner/>
:
<section>
{
this.state.storeInfo.logo.url
?
<img src={ this.state.storeInfo.logo.url } className="img-fluid img-thumbnail" />
:
<h5>{ this.state.storeInfo.name }</h5>
}
<ul className="list-group">
<li className="list-group-item">
<div className="d-flex w-100 justify-content-between">
<h5 className="mb-1">Domain</h5>
</div>
<p className="mb-1">{ this.state.storeInfo.domain }</p>
</li>
<li className="list-group-item">
<div className="d-flex w-100 justify-content-between">
<h5 className="mb-1">Secure URL</h5>
</div>
<p className="mb-1">{ this.state.storeInfo.secure_url }</p>
</li>
</ul>
</section>
}
</div>
</div>
</div>
</div>
</div>
);
}
}
resources/js/screens/list.js
import React from 'react';
import {Spinner, Table} from '../components';
import {ApiService} from '../services/ApiService';
export default class List extends React.Component {
constructor(props) {
super(props);
this.state = {
isOrdersLoading: true,
orders: {
data: [],
pagination: {},
},
tableHeaders:
[
{
label: "Order ID",
index: "id",
callback: function(orderId) {
return orderId;
},
},
{
label: "Billing Name",
index: "billing_address",
callback: function(billingAddress) {
return `${billingAddress.first_name} ${billingAddress.last_name}`;
},
},
{
label: "Order Total",
index: "total_inc_tax",
callback: function(orderTotal) {
return orderTotal;
},
},
{
label: "Order Status",
callback: function(data) {
let badgeClass = 'badge badge-';
if (data.status_id === 5) {
badgeClass += 'danger';
} else if (data.status_id === 2 || data.status_id === 10) {
badgeClass += 'success';
} else {
badgeClass += 'light';
}
return (
<span className={ badgeClass }>{ data.status }</span>
);
},
},
{
label: "Actions",
callback: function(data) {
if (data.status_id !== 5) {
return (
<button type="button" className="btn btn-danger" onClick={(e) => this.cancelOrder(data.id, e)}>Cancel</button>
);
}
}.bind(this),
},
],
};
}
componentWillMount() {
this.loadOrders();
}
loadOrders() {
ApiService.getOrders({
limit: 5
}).then(this.handleOrdersResponse.bind(this));
}
handleOrdersResponse(response) {
this.setState({
isOrdersLoading: false,
orders: {
data: response.data
}
});
}
cancelOrder(orderId) {
const newOrderData = { status_id: 5 };
this.setState({
isOrdersLoading: true,
});
ApiService.updateOrder(orderId, newOrderData)
.then(this.loadOrders.bind(this));
}
hasOrders() {
return (this.state.orders.data.length > 0);
}
render() {
return (
<div className="container">
<div className="row">
<div className="col-md-12">
<div className="card">
<div className="card-header">List Orders</div>
<div className="card-body">
{
this.state.isOrdersLoading
?
<Spinner/>
:
this.hasOrders()
?
<section>
<Table tableHeaders={this.state.tableHeaders} tableData={this.state.orders.data} />
</section>
:
<section>
<div className="emptyTable">No orders exist yet!</div>
</section>
}
</div>
</div>
</div>
</div>
</div>
);
}
}
And as the final step, compile the JS assets again:
npm run dev
After a successful compile, you’ll now have a functional Laravel React app which can be loaded inside of BigCommerce!
If you got this far, congrats! You have a great base to work on as you experiment with all the BigCommerce APIs.
To launch a real app, aside from hosting it on a server other than your dev box, you’ll still need to add some persistent storage for API credentials, storing the store and user info received from the OAuth token request during app install so users can load the app after the initial session expires. Error handling, especially for failed requests to the API, should be handled and surfaced to the merchant. And tests, once you get to a state you are reasonably happy with, will help keep regressions at bay.
https://github.com/bigcommerce/laravel-react-sample-app/releases/tag/1.0
#laravel #reactjs #javascript #web-development
1598839687
If you are undertaking a mobile app development for your start-up or enterprise, you are likely wondering whether to use React Native. As a popular development framework, React Native helps you to develop near-native mobile apps. However, you are probably also wondering how close you can get to a native app by using React Native. How native is React Native?
In the article, we discuss the similarities between native mobile development and development using React Native. We also touch upon where they differ and how to bridge the gaps. Read on.
Let’s briefly set the context first. We will briefly touch upon what React Native is and how it differs from earlier hybrid frameworks.
React Native is a popular JavaScript framework that Facebook has created. You can use this open-source framework to code natively rendering Android and iOS mobile apps. You can use it to develop web apps too.
Facebook has developed React Native based on React, its JavaScript library. The first release of React Native came in March 2015. At the time of writing this article, the latest stable release of React Native is 0.62.0, and it was released in March 2020.
Although relatively new, React Native has acquired a high degree of popularity. The “Stack Overflow Developer Survey 2019” report identifies it as the 8th most loved framework. Facebook, Walmart, and Bloomberg are some of the top companies that use React Native.
The popularity of React Native comes from its advantages. Some of its advantages are as follows:
Are you wondering whether React Native is just another of those hybrid frameworks like Ionic or Cordova? It’s not! React Native is fundamentally different from these earlier hybrid frameworks.
React Native is very close to native. Consider the following aspects as described on the React Native website:
Due to these factors, React Native offers many more advantages compared to those earlier hybrid frameworks. We now review them.
#android app #frontend #ios app #mobile app development #benefits of react native #is react native good for mobile app development #native vs #pros and cons of react native #react mobile development #react native development #react native experience #react native framework #react native ios vs android #react native pros and cons #react native vs android #react native vs native #react native vs native performance #react vs native #why react native #why use react native
1625050361
React Native is the most popular dynamic framework that provides the opportunity for Android & iOS users to download and use your product. Finding a good React Native development company is incredibly challenging. Use our list as your go-to resource for React Native app development Companies in USA.
List of Top-Rated React Native Mobile App Development Companies in USA:
A Brief about the company details mentioned below:
1. AppClues Infotech
As a React Native Mobile App Development Company in USA, AppClues Infotech offers user-centered mobile app development for iOS & Android. Since their founding in 2014, their React Native developers create beautiful mobile apps.
They have a robust react native app development team that has high knowledge and excellent strength of developing any type of mobile app. They have successfully delivered 450+ mobile apps as per client requirements and functionalities.
Website: https://www.appcluesinfotech.com/
2. WebClues Infotech
WebClues Infotech is the Top-Notch React Native mobile app development company in USA & offering exceptional service worldwide. Since their founding in 2014, they have completed 950+ web & mobile apps projects on time.
They have the best team of developers who has an excellent knowledge of developing the most secure, robust & Powerful React Native Mobile Apps. From start-ups to enterprise organizations, WebClues Infotech provides top-notch React Native App solutions that meet the needs of their clients.
Website: https://www.webcluesinfotech.com/
3. AppClues Studio
AppClues Studio is one of the top React Native mobile app development company in USA and offers the best service worldwide at an affordable price. They have a robust & comprehensive team of React Native App developers who has high strength & extensive knowledge of developing any type of mobile apps.
Website: https://www.appcluesstudio.com/
4. WebClues Global
WebClues Global is one of the best React Native Mobile App Development Company in USA. They provide low-cost & fast React Native Development Services and their React Native App Developers have a high capability of serving projects on more than one platform.
Since their founding in 2014, they have successfully delivered 721+ mobile app projects accurately. They offer versatile React Native App development technology solutions to their clients at an affordable price.
Website: https://www.webcluesglobal.com/
5. Data EximIT
Hire expert React Native app developer from top React Native app development company in USA. Data EximIT is providing high-quality and innovative React Native application development services and support for your next projects. The company has been in the market for more than 8 years and has already gained the trust of 553+ clients and completed 1250+ projects around the globe.
They have a large pool of React Native App developers who can create scalable, full-fledged, and appealing mobile apps to meet the highest industry standards.
Website: https://www.dataeximit.com/
6. Apptunix
Apptunix is the best React Native App Development Company in the USA. It was established in 2013 and vast experience in developing React Native apps. After developing various successful React Native Mobile Apps, the company believes that this technology helps them incorporate advanced features in mobile apps without influencing the user experience.
Website: https://www.apptunix.com/
7. BHW Group
BHW Group is a Top-Notch React Native Mobile App Development Company in the USA. The company has 13+ years of experience in providing qualitative app development services to clients worldwide. They have a compressive pool of React Native App developers who can create scalable, full-fledged, and creative mobile apps to meet the highest industry standards.
Website: https://thebhwgroup.com/
8. Willow Tree:
Willow Tree is the Top-Notch React Native Mobile App Development Company in the USA & offering exceptional React Native service. They have the best team of developers who has an excellent knowledge of developing the most secure, robust & Powerful React Native Mobile Apps. From start-ups to enterprise organizations, Willow Tree has top-notch React Native App solutions that meet the needs of their clients.
Website: https://willowtreeapps.com/
9. MindGrub
MindGrub is a leading React Native Mobile App Development Company in the USA. Along with React Native, the company also works on other emerging technologies like robotics, augmented & virtual reality. The Company has excellent strength and the best developers team for any type of React Native mobile apps. They offer versatile React Native App development technology solutions to their clients.
Website: https://www.mindgrub.com/
10. Prismetric
Prismetric is the premium React Native Mobile App Development Company in the USA. They provide fast React Native Development Services and their React Native App Developers have a high capability of serving projects on various platforms. They focus on developing customized solutions for specific business requirements. Being a popular name in the React Native development market, Prismetric has accumulated a specialty in offering these services.
Website: https://www.prismetric.com/
#top rated react native app development companies in usa #top 10 react native app development companies in usa #top react native app development companies in usa #react native app development technologies #react native app development #hire top react native app developers in usa
1595059664
With more of us using smartphones, the popularity of mobile applications has exploded. In the digital era, the number of people looking for products and services online is growing rapidly. Smartphone owners look for mobile applications that give them quick access to companies’ products and services. As a result, mobile apps provide customers with a lot of benefits in just one device.
Likewise, companies use mobile apps to increase customer loyalty and improve their services. Mobile Developers are in high demand as companies use apps not only to create brand awareness but also to gather information. For that reason, mobile apps are used as tools to collect valuable data from customers to help companies improve their offer.
There are many types of mobile applications, each with its own advantages. For example, native apps perform better, while web apps don’t need to be customized for the platform or operating system (OS). Likewise, hybrid apps provide users with comfortable user experience. However, you may be wondering how long it takes to develop an app.
To give you an idea of how long the app development process takes, here’s a short guide.
_Average time spent: two to five weeks _
This is the initial stage and a crucial step in setting the project in the right direction. In this stage, you brainstorm ideas and select the best one. Apart from that, you’ll need to do some research to see if your idea is viable. Remember that coming up with an idea is easy; the hard part is to make it a reality.
All your ideas may seem viable, but you still have to run some tests to keep it as real as possible. For that reason, when Web Developers are building a web app, they analyze the available ideas to see which one is the best match for the targeted audience.
Targeting the right audience is crucial when you are developing an app. It saves time when shaping the app in the right direction as you have a clear set of objectives. Likewise, analyzing how the app affects the market is essential. During the research process, App Developers must gather information about potential competitors and threats. This helps the app owners develop strategies to tackle difficulties that come up after the launch.
The research process can take several weeks, but it determines how successful your app can be. For that reason, you must take your time to know all the weaknesses and strengths of the competitors, possible app strategies, and targeted audience.
The outcomes of this stage are app prototypes and the minimum feasible product.
#android app #frontend #ios app #minimum viable product (mvp) #mobile app development #web development #android app development #app development #app development for ios and android #app development process #ios and android app development #ios app development #stages in app development
1621573085
Expand your user base by using react-native apps developed by our expert team for various platforms like Android, Android TV, iOS, macOS, tvOS, the Web, Windows, and UWP.
We help businesses to scale up the process and achieve greater performance by providing the best react native app development services. Our skilled and experienced team’s apps have delivered all the expected results for our clients across the world.
To achieve growth for your business, hire react native app developers in India. You can count on us for all the technical services and support.
#react native app development company india #react native app developers india #hire react native developers india #react native app development company #react native app developers #hire react native developers
1595491178
The electric scooter revolution has caught on super-fast taking many cities across the globe by storm. eScooters, a renovated version of old-school scooters now turned into electric vehicles are an environmentally friendly solution to current on-demand commute problems. They work on engines, like cars, enabling short traveling distances without hassle. The result is that these groundbreaking electric machines can now provide faster transport for less — cheaper than Uber and faster than Metro.
Since they are durable, fast, easy to operate and maintain, and are more convenient to park compared to four-wheelers, the eScooters trend has and continues to spike interest as a promising growth area. Several companies and universities are increasingly setting up shop to provide eScooter services realizing a would-be profitable business model and a ready customer base that is university students or residents in need of faster and cheap travel going about their business in school, town, and other surrounding areas.
In many countries including the U.S., Canada, Mexico, U.K., Germany, France, China, Japan, India, Brazil and Mexico and more, a growing number of eScooter users both locals and tourists can now be seen effortlessly passing lines of drivers stuck in the endless and unmoving traffic.
A recent report by McKinsey revealed that the E-Scooter industry will be worth― $200 billion to $300 billion in the United States, $100 billion to $150 billion in Europe, and $30 billion to $50 billion in China in 2030. The e-Scooter revenue model will also spike and is projected to rise by more than 20% amounting to approximately $5 billion.
And, with a necessity to move people away from high carbon prints, traffic and congestion issues brought about by car-centric transport systems in cities, more and more city planners are developing more bike/scooter lanes and adopting zero-emission plans. This is the force behind the booming electric scooter market and the numbers will only go higher and higher.
Companies that have taken advantage of the growing eScooter trend develop an appthat allows them to provide efficient eScooter services. Such an app enables them to be able to locate bike pick-up and drop points through fully integrated google maps.
It’s clear that e scooters will increasingly become more common and the e-scooter business model will continue to grab the attention of manufacturers, investors, entrepreneurs. All this should go ahead with a quest to know what are some of the best electric bikes in the market especially for anyone who would want to get started in the electric bikes/scooters rental business.
We have done a comprehensive list of the best electric bikes! Each bike has been reviewed in depth and includes a full list of specs and a photo.
https://www.kickstarter.com/projects/enkicycles/billy-were-redefining-joyrides
To start us off is the Billy eBike, a powerful go-anywhere urban electric bike that’s specially designed to offer an exciting ride like no other whether you want to ride to the grocery store, cafe, work or school. The Billy eBike comes in 4 color options – Billy Blue, Polished aluminium, Artic white, and Stealth black.
Price: $2490
Available countries
Available in the USA, Europe, Asia, South Africa and Australia.This item ships from the USA. Buyers are therefore responsible for any taxes and/or customs duties incurred once it arrives in your country.
Features
Specifications
Why Should You Buy This?
**Who Should Ride Billy? **
Both new and experienced riders
**Where to Buy? **Local distributors or ships from the USA.
Featuring a sleek and lightweight aluminum frame design, the 200-Series ebike takes your riding experience to greater heights. Available in both black and white this ebike comes with a connected app, which allows you to plan activities, map distances and routes while also allowing connections with fellow riders.
Price: $2099.00
Available countries
The Genze 200 series e-Bike is available at GenZe retail locations across the U.S or online via GenZe.com website. Customers from outside the US can ship the product while incurring the relevant charges.
Features
Specifications
https://ebikestore.com/shop/norco-vlt-s2/
The Norco VLT S2 is a front suspension e-Bike with solid components alongside the reliable Bosch Performance Line Power systems that offer precise pedal assistance during any riding situation.
Price: $2,699.00
Available countries
This item is available via the various Norco bikes international distributors.
Features
Specifications
http://www.bodoevs.com/bodoev/products_show.asp?product_id=13
Manufactured by Bodo Vehicle Group Limited, the Bodo EV is specially designed for strong power and extraordinary long service to facilitate super amazing rides. The Bodo Vehicle Company is a striking top in electric vehicles brand field in China and across the globe. Their Bodo EV will no doubt provide your riders with high-level riding satisfaction owing to its high-quality design, strength, breaking stability and speed.
Price: $799
Available countries
This item ships from China with buyers bearing the shipping costs and other variables prior to delivery.
Features
Specifications
#android app #autorent #entrepreneurship #ios app #minimum viable product (mvp) #mobile app development #news #app like bird #app like bounce #app like lime #autorent #best electric bikes 2020 #best electric bikes for rental business #best electric kick scooters 2020 #best electric kickscooters for rental business #best electric scooters 2020 #best electric scooters for rental business #bird scooter business model #bird scooter rental #bird scooter rental cost #bird scooter rental price #clone app like bird #clone app like bounce #clone app like lime #electric rental scooters #electric scooter company #electric scooter rental business #how do you start a moped #how to start a moped #how to start a scooter rental business #how to start an electric company #how to start electric scooterrental business #lime scooter business model #scooter franchise #scooter rental business #scooter rental business for sale #scooter rental business insurance #scooters franchise cost #white label app like bird #white label app like bounce #white label app like lime