How to distinguish between SharePoint 2016 and 2019 programmatically

%3CLINGO-SUB%20id%3D%22lingo-sub-1943233%22%20slang%3D%22en-US%22%3EHow%20to%20distinguish%20between%20SharePoint%202016%20and%202019%20programmatically%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1943233%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20common%20solution%20for%20SharePoint%202016%20and%202019%20Servers.%20The%20solution%20has%20both%20client%20side%20(JavaScript)%20and%20server%20side%20(SSOM%20and%20CSOM)%20components.%20For%20some%20modern%20UI%20related%20work%2C%20I%20need%20to%20find%20out%20if%20solution%20is%20running%20on%202019%20or%202016.%20Since%20both%20have%20same%20major%20version%20(16)%2C%20what%20is%20the%20best%20way%20to%20do%20it%3F%3C%2FP%3E%3CP%3EIn%20script%2C%20is%20it%20Ok%20to%20check%20if%20modernThemingEnabled%20property%20is%20available%20in%20_spPageContextInfo%3F%3C%2FP%3E%3CP%3EFor%20server%20side%20code%2C%20is%20there%20any%20feature%20that%20I%20can%20check%20in%20sites%20or%20what%20is%20the%20best%20way%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1943233%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Eshare%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Visitor

I have a common solution for SharePoint 2016 and 2019 Servers. The solution has both client side (JavaScript) and server side (SSOM and CSOM) components. For some modern UI related work, I need to find out if solution is running on 2019 or 2016. Since both have same major version (16), what is the best way to do it?

In script, is it Ok to check if modernThemingEnabled property is available in _spPageContextInfo?

For server side code, is there any feature that I can check in sites or what is the best way?

1 Reply
Can you share some details of what you are looking to achieve?