Install and test connector

How do I install and test a Connector package?

All our supporting packages (@xdn/next, @xdn/nuxt, @xdn/svelte, and so on) are implemented using the connectors so whenever you use one, you are using the Connector feature.

If you want to write a custom connector for your site, you can do that by adding connector entry points to your repository directly and setting connector value to a relative path where these entry points are stored. For example, if you are customizing only the prod entry point you would have:


and in xdn.config.js:

  connector: './xdn-scripts' 

Does that help?

Yes, that’s helpful @ierceg. Thank you.

It sounds like what you’re proposing with adding connector entry points directly to my codebase would work for a one-off integration.

However, if I want to create a reusable connector package for a framework how would I install the local package into my codebase and test it locally?

Right, I was proposing one-off integration. If you want to create a reusable connector then it’s the matter of following the guide and publishing your connector on the NPM. Of course you could also test it before then by using yalc. In short you would:

  1. In the root of your reusable connector package, run yalc publish.
  2. In the root of your test project, run yalc add my-connector-package (assuming the name of your package is my-connector-package)
  3. In the xdn.config.js, set connector to my-connector-package.

Let me know how this works for you.

@ierceg steps 1 and 2 make sense but I’m not sure I understand step 3.

For additional context, I am attempting to create a custom Sapper connector, based on the examples in the Connectors guide.

If I understand correctly, xdn.config.js is in my custom connector until after xdn init is run and it is copied into the project.

However, xdn init just pulls in the official published packaged.

How do I xdn init with my custom connector?

Step 3 would have to be done after you ran xdn init. xdn init itself will try to detect a framework but if it fails it still creates xdn.config.js, it’s just leaves it empty:

// This file was automatically added by xdn deploy.
// You should commit this file to source control.
module.exports = {}

After that you edit it per step 3 from the above. At the moment you cannot register your custom framework to use it as part of the framework detection process.

I’ve filed a ticket XDN-7939 to allow to specify a framework during xdn init.

We’ve updated the connectors guides with new sections on running your connector locally, either as a package or as a directory within your project:

You can also run xdn init with a specific connector:

$ xdn init --connector=my-connector-package