Laravel-Inertia-React Boilerplate Documentation

Project Setup

Follow these steps to set up the boilerplate for your Shopify app (embedded and non-embedded).

1. Clone the Project

First, clone the repository to your local machine:

2. Database Configuration

- Database Type: MySQL

- Configure your .env file with your database credentials:

3. Install Composer Dependencies

Next, install the PHP dependencies using Composer:

4. Install NPM Packages

After that, install the JavaScript dependencies with NPM:

5. Run Database Migrations

Set up your database by running the migrations:

6. Queue Configuration

By default, this project uses a database queue connection. If you're using Cloudways, you should change the queue connection to Redis:

  1. Update your .env file:
  2. In the config/queue.php file, ensure your settings look like this:

7. Shopify App Credentials

Add your Shopify app credentials to the .env file:

8. Session Settings for Embedded Apps

For embedded apps, add the following session settings to your .env file to preserve logged-in user details:

9. Routes Setup

To set up the routes for your application:

  1. If your app is embedded, copy the code from routes/embedded_example_web.php to routes/web.php.
  2. If your app is non-embedded, copy the code from routes/non_embedded_example_web.php to routes/web.php.

10. Additional Steps for Shopify Integration

In your Shopify app configuration:

  1. Add the App URL:
  2. In the Allowed redirection URL(s), add:
  3. Check Embedded App as true for embedded apps and false for non-embedded apps.
  4. Save the changes.

11. React Code Integration

In your React components, if your app is embedded, make sure to import the necessary hook from Inertia:

You can then extract the query parameters like this:

Use the extracted query with every route you call in your app. For example:

Note: For non-embedded apps, there is no need for this integration.

12. Running the Application

To start the development server, run:

Then, in a separate terminal, run:

13. Accessing the Application

You can access your application at:

Notes