We’re excited to announce new support for user choice of Gaia hub during onboarding.
Developers can opt to enable the functionality described below for new users who prefer to use their own Gaia hubs instead of the one provided by Blockstack PBC.
This is new and rather experimental functionality, so we’re looking for early feedback from the developer community to make it better. Please test it out and tell us what you think!
You can also try out this new functionality with our test application before integrating it yourself.
Users will need to authenticate with the browser hosted by Blockstack PBC or download the latest version of the browser (0.35.1) to their macOS, Windows or Linux devices to encounter this new functionality during onboarding once enabled by developers for the apps they use.
Note that this feature is currently available only to new users on Blockstack, not existing ones. We have yet to develop support for data migration between Gaia hubs. We plan to release support for existing users once we hub migration is possible.
Enable the Gaia hub URL option for new users
During onboarding, new users are assigned by default to a Gaia hub hosted by Blockstack PBC. This gets them started without requiring that they host and configure their own Gaia hubs.
However, a major tenet of Blockstack’s mission is to empower users to make their own choice regarding where to store their data. And we believe that most users would ultimately benefit most from storing their data outside of Blockstack PBC’s control. Users themselves – not not any developer or platform – should own and manage their app data.
As a step towards fulfilling this principle, we’re now empowering developers to enable a new prompt for users who want to provide the URL to a Gaia hub they’ve either hosted themselves or been granted permission to use by someone else.
If a developer enables this feature, new users will see this modal after entering their passwords:
The user can then choose to continue with Blockstack PBC’s default Gaia hub (indicated here as “Blockstack’s official provider”) or configure their own (by selecting “Use different provider”).
If the user chooses “Use different provider”, they’ll encounter a modal that asks them to provide the URL for the Gaia hub of their choice:
Note that the Gaia hub hosted by Blockstack PBC is located at https://hub.blockstack.org. Any user who wishes to use a different hub will need to host it at their own HTTPS address. They can also can enter the HTTPS address of a hub hosted by someone else and made available to them.
Once the user submits the above form, they will proceed as normal through the flow. But any data they generate while using apps that store data through Blockstack’s Gaia technology will be stored to their indicated hub instead of the hub hosted by Blockstack PBC.
To enable this feature as a developer, you first need to upgrade to the latest version of blockstack.js.
Then, modify your sign-in flow to apply the solicitGaiaHubUrl parameter with value true when executing the makeAuthRequest method:
import {
makeAuthRequest,
redirectToSignInWithAuthRequest
} from 'blockstack';
const authRequest = makeAuthRequest(
generateAndStoreTransitKey(),
'http://localhost:8080/',
'http://localhost:8080/manifest.json',
['store_write', 'publish_data'],
'http://localhost:8080/',
nextHour().getTime(), {
solicitGaiaHubUrl: true
} // new options param
);
redirectToSignInWithAuthRequest(authRequest);
Note that by setting all of those first parameters to undefined, you’re opting to use just the default value for those arguments. See the docs for makeAuthRequest for more info.
Recommend a Gaia hub URL for new users
Are you a developer who wants to create specific funnels for users who may want to use the same Gaia hub while creating their Blockstack IDs?
We’ve also released the ability to pass a preset Gaia hub URL when sending these new users through the onboarding flow.
For example, if you have a corporate client whose employees would all like to use your application with a company-run Gaia hub, you can create a funnel that passes that company’s hosted Gaia hub URL.
Simply provide an additional recommendedGaiaHubUrl value alongside the solicitGaiaHubUrl indicated in the previous section above:
import {
makeAuthRequest,
redirectToSignInWithAuthRequest
} from 'blockstack';
const authRequest = makeAuthRequest(undefined, undefined, undefined, undefined, undefined, undefined, {
solicitGaiaHubUrl: true,
recommendedGaiaHubUrl: 'https://mygaiahub.com'
});
const authRequest = makeAuthRequest(
generateAndStoreTransitKey(),
'http://localhost:8080/',
'http://localhost:8080/manifest.json',
['store_write', 'publish_data'],
'http://localhost:8080/',
nextHour().getTime(), {
solicitGaiaHubUrl: true, //new options param
recommendedGaiaHubUrl: 'https://mygaiahub.com' // new options param
}
);
redirectToSignInWithAuthRequest(authRequest);
New users will subsequently encounter the following modal after entering their passwords:
These users can consequently choose to apply the recommended Gaia hub (whose URL is indicated in the grey area near the top), the hub hosted Blockstack PBC (indicated as “Blockstack’s provider”), or an entirely different one (“Use different provider”), leading to the same Gaia hub URL form as in the section above.