I have found loads of guides showing how to do this, but none if them show how to do it using the client side model.
This should do what i want, but its using the server side model and not the client side.
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.Sign up to join this community
Yes, you can add webparts using the client side object model.
Adding webparts is generally considered part of a provisioning solution and the OfficeDev Patterns and Practices (PnP) repository on GitHub has many examples that demonstrate different provisioning techniques.
One specific scenario that demonstrates inserting a webpart from an add-in into a hostweb is called
Core.AppScriptPart, you'll find the repository folder for it at https://github.com/OfficeDev/PnP/tree/master/Samples/Core.AppScriptPart
Andrew Connell created a video hosted on Channel9 that describes the solution and it's technique as well as the PnP program in general.
To see the nuts and bolts of how the solution works, navigate to the code for
This solution uses a .webpart file loaded into SharePoint as part of the add-in (the file is contained in the solution) then uses the CSOM to upload that file into the host web's
Web Part Gallery list.
There are also other solutions that demonstrate how to add webparts to pages using the
LimitedWebPartManager which is available in the CSOM, you can find that example in
/Samples/Core.UploadWebPart/Core.UploadWebPartWeb/Pages/Default.aspx.cs in the function on line 84 called
You not can add webpart with client side object model because the client side object model not have Farm scope. For to do this you need Farm scope.