New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

drupal-decoupled

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

drupal-decoupled

Drupal utils for Decoupled integrations

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27
decreased by-65.38%
Maintainers
1
Weekly downloads
 
Created
Source

Drupal-Decoupled

A list of utilities for a Decoupled integrations

Route Syncronization and comunication between FE and BE via the Iframe

Import the syncDrupalPreviewRoutes helper at app/root.tsx

import { syncDrupalPreviewRoutes } from "drupal-decoupled";

Make sure your loader returns the current environment value

export const loader = async ({ context }: LoaderFunctionArgs ) => {
  // Provide a variable to define the environment
  const environment = context.cloudflare.env.ENVIRONMENT
  return json(
    {
      environment,
    },
    { status: 200 }
  );
};

NOTE: This example is using Cloudflare and taking advantage of Environemt Settings to define "environment" key/value, that is why we are using the context.cloudflare.env.ENVIRONMENT object to obtain the value and pass it from Server to Client.

Upate your App function

export default function App() {
  // read environment from loader
  const { environment } = useLoaderData<typeof loader>();
  // use the useNavigation hook from @remix-run/react
  const navigation = useNavigation();

  // check if environment is preview and navigation.state is loading
  // to call syncDrupalPreviewRoutes
  if (environment === "preview" && navigation.state === "loading") {
    syncDrupalPreviewRoutes(navigation.location.pathname);
  }

  return (
    <>
      <Outlet />
    </>
  );
}

For a fully functional example visit any of those repositories:

  • GraphQL:

    • Remix
    • Drupal
  • JSON:API (TBD)

Supporting organizations

Development sponsored by Octahedroid

Keywords

FAQs

Package last updated on 23 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc