files/en-us/web/api/xrframe/createanchor/index.md
{{APIRef("WebXR Device API")}}{{SeeCompatTable}}{{SecureContext_Header}}
The createAnchor() method of the {{domxref("XRFrame")}} interface creates a free-floating {{domxref("XRAnchor")}} which will be fixed relative to the real world.
See {{domxref("XRHitTestResult.createAnchor()")}} for creating an anchor from a hit test result that is attached to a real-world object.
createAnchor(pose, space)
pose
space
A {{jsxref("Promise")}} resolving to an {{domxref("XRAnchor")}} object.
frame.createAnchor(anchorPose, referenceSpace).then(
(anchor) => {
// Do stuff with the anchor (assign objects that will be relative to this anchor)
},
(error) => {
console.error(`Could not create anchor: ${error}`);
},
);
{{Specifications}}
{{Compat}}